【Follow me Season 2 Episode 1】Introductory Task - Light up the onboard LED
[Copy link]
There are two types of CPX (LED and neopixel) with a total of 12 lamp beads.
The On button on the right side of the USB port is the power indicator light and is generally not used for programming.
So in this task, the programming object is the D13 LED lamp bead on the left side of the USB port.
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
while True:
print("Hello, EEworld!")
led.value = not led.value
time.sleep(0.5)
Main logic
After initializing the LED light, in the big loop, print a piece of content and change the value of the LED, that is, the light is on and off, and finally sleep to enter the next loop
Tail
Careful friends will find out why the D13 pin does not appear in the code?
Let me run it in interactive environment
>>> import board;help(board)
You will see some definitions and aliases that CircuitPython has defined for the board.
That's why D13 didn't appear.
Not only LEDs, but some other onboard sensors have also been defined by CircuitPython. You can check more by yourself.
This is one of the reasons why I like CircuitPython.
|