-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpixel.py
More file actions
26 lines (18 loc) · 815 Bytes
/
pixel.py
File metadata and controls
26 lines (18 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import time
import board
from rainbowio import colorwheel
import neopixel
PIN = board.D18 # This is the default pin on the 5x5 NeoPixel Grid BFF.
NUMPIXELS = 10 # Update this to match the number of LEDs.
SPEED = 0.0015 # Increase to slow down the rainbow. Decrease to speed it up.
BRIGHTNESS = 0.2 # A number between 0.0 and 1.0, where 0.0 is off, and 1.0 is max.
pixels = neopixel.NeoPixel(PIN, NUMPIXELS, brightness=BRIGHTNESS, auto_write=False)
def rainbow_cycle(wait):
for color in range(255):
for pixel in range(len(pixels)): # pylint: disable=consider-using-enumerate
pixel_index = (pixel * 256 // len(pixels)) + color * 5
pixels[pixel] = colorwheel(pixel_index & 255)
pixels.show()
time.sleep(wait)
while True:
rainbow_cycle(SPEED)