Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gallaugher/36097170764174b2c170cc8b0d5c38a1 to your computer and use it in GitHub Desktop.
Save gallaugher/36097170764174b2c170cc8b0d5c38a1 to your computer and use it in GitHub Desktop.
roy-g-biv-pico-flash-with-each-color-off.py
# roy-g-biv-pico-flash-with-each-color-off.py
import board, time, neopixel
# define colors:
RED = (255, 0, 0)
ORANGE = (255, 40, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
INDIGO = (75, 0, 130) # no official INDIGO from CircuitPython
VIOLET = (180, 0, 255) # PURPLE
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
# setup NeoPixel object named "strip"
strip = neopixel.NeoPixel(board.GP16, 30, brightness=0.5)
# turn off all lights to start
strip.fill((0, 0, 0))
# Create a variable to hold the time to pause each color
color_pause = 0.5
off_pause = 0.5
print("roy-g-biv-pico-flash-with-each-color-off running!")
while True:
strip.fill(RED)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
strip.fill(ORANGE)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
strip.fill(YELLOW)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
strip.fill(GREEN)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
strip.fill(BLUE)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
strip.fill(INDIGO)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
strip.fill(VIOLET)
time.sleep(color_pause)
strip.fill(BLACK) # BLACK
time.sleep(off_pause)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment