code.py
1 # SPDX-FileCopyrightText: 2017 Limor Fried for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import time 6 import board 7 from rainbowio import colorwheel 8 import neopixel 9 10 pixpin = board.D1 11 numpix = 60 12 13 strip = neopixel.NeoPixel(pixpin, numpix, brightness=1, auto_write=True) 14 15 16 # Fill the dots one after the other with a color 17 def colorWipe(color, wait): 18 for j in range(len(strip)): 19 strip[j] = (color) 20 time.sleep(wait) 21 22 23 def rainbow_cycle(wait): 24 for j in range(255): 25 for i in range(len(strip)): 26 idx = int((i * 256 / len(strip)) + j) 27 strip[i] = colorwheel(idx & 255) 28 time.sleep(wait) 29 30 31 def rainbow(wait): 32 for j in range(255): 33 for i in range(len(strip)): 34 idx = int(i + j) 35 strip[i] = colorwheel(idx & 255) 36 time.sleep(wait) 37 38 39 while True: 40 colorWipe((255, 0, 0), .05) # red and delay 41 colorWipe((0, 255, 0), .05) # green and delay 42 colorWipe((0, 0, 255), .05) # blue and delay 43 44 rainbow(0.02) 45 rainbow_cycle(0.02)