from machine import Pin
from neopixel import NeoPixel
from time import sleep_ms
LED_COUNT = 5
LEVEL = 24 # A dim first test for one USB-powered board.
HOLD_MS = 1000
pixels = NeoPixel(Pin(0, Pin.OUT), LED_COUNT) # GP0, physical pin 1, via 74AHCT125.
try:
while True:
for colour in ((LEVEL, 0, 0), (0, LEVEL, 0), (0, 0, LEVEL)):
pixels.fill(colour) # Tuples are (red, green, blue).
pixels.write() # Transmit the buffered colours.
sleep_ms(HOLD_MS)
finally:
pixels.fill((0, 0, 0))
pixels.write()
Shared from Little Bird Electronics curriculum.