while True:
led.value = True
time.sleep(0.1)
led.value = False
time.sleep(0.1)
Now it blinks really fast! You decreased the both time that the code leaves the LED on
and off!
Now try increasing both of the 0.1 to 1 . Your LED will blink much more slowly
because you've increased the amount of time that the LED is turned on and off.
Well done! You're doing great! You're ready to start into new examples and edit them
to see what happens! These were simple changes, but major changes are done using
the same process. Make your desired change, save it, and get the results. That's
really all there is to it!
Naming Your Program File
CircuitPython looks for a code file on the board to run. There are four options: code.tx
t, code.py, main.txt and main.py. CircuitPython looks for those files, in that order, and
then runs the first one it finds. While code.py is the recommended name for your code
file, it is important to know that the other options exist. If your program doesn't seem
to be updating as you work, make sure you haven't created another code file that's
being read instead of the one you're working on.
Exploring Your First CircuitPython Program
First, you'll take a look at the code you're editing.
Here is the original code again:
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
©Adafruit Industries Page 48 of 263