LED-Ring
import time
import board
import neopixel
pixel_pin = board.D21
num_pixels =
8
ORDER = neopixel.GRB
pixels = neopixel.NeoPixel(
pixel_pin, num_pixels, brightness=0.2, auto_write=False,
pixel_order=ORDER
)
def
wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if
pos <
0
r = g = b =
elif
pos < 85:
r = int(pos * 3)
g =
int(255
b =
0
elif
pos < 170:
pos -=
r =
int(255
g =
0
b = int(pos * 3)
else:
pos -=
r =
0
g = int(pos * 3)
b =
int(255
return
(r, g, b)
0)
def
rainbow_cycle(wait):
for
j
in
range(255):
Code-Beispiel
or
pos > 255:
0
- pos * 3)
85
- pos * 3)
170
- pos * 3)
if
ORDER
in
(neopixel.RGB, neopixel.GRB)
else
(r, g, b,
22