Little Bird Curriculum / code littlebird.com.au
lorikeet_pico.py MicroPython 18 lines · 2 views Raw Download Embed view
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()

Embed this snippet

As an iframe:

Or drop it inline with a script tag (injects the highlighted block where included):

Shared from Little Bird Electronics curriculum.

Copied to clipboard