-
Notifications
You must be signed in to change notification settings - Fork 1
/
nak3.py
36 lines (31 loc) · 842 Bytes
/
nak3.py
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
27
28
29
30
31
32
33
34
35
36
import time
import board
from rainbowio import colorwheel
import neopixel
import random
pixel_pin = board.GP1
num_pixels = 9
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.2, auto_write=False)
OFF = (0, 0, 0)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (180, 180, 180)
colors = [RED, GREEN, CYAN, BLUE, PURPLE, WHITE]
pre_color = OFF
color = OFF
while True:
leds = []
pixels.fill(YELLOW)
for _ in range(random.randint(2, num_pixels - 3)):
leds.append(random.randint(0, num_pixels - 1))
while pre_color == color:
color = colors[random.randint(0, len(colors) - 1)]
pre_color = color
for n in leds:
pixels[n] = color
pixels.show()
time.sleep((random.randint(2, 10) * 100) / 1000)