]> vault307.fbx.one Git - Sensory_Wall.git/blob - demoRGB.py
more sensory wall projects
[Sensory_Wall.git] / demoRGB.py
1 import machine, neopixel, time
2 np=neopixel.NeoPixel(machine.Pin(0), 96)
3
4 def demo(np):
5 n = np.n
6
7 # cycle
8 for i in range(4 * n):
9 for j in range(n):
10 np[j] = (0, 0, 0)
11 np[i % n] = (255, 255, 255)
12 np.write()
13 time.sleep_ms(25)
14
15 # bounce
16 for i in range(4 * n):
17 for j in range(n):
18 np[j] = (0, 128, 128)
19 if (i // n) % 2 == 0:
20 np[i % n] = (0, 0, 0)
21 else:
22 np[n - 1 - (i % n)] = (0, 0, 0)
23 np.write()
24 time.sleep_ms(60)
25
26 # fade in/out
27 for i in range(0, 4 * 256, 8):
28 for j in range(n):
29 if (i // 256) % 2 == 0:
30 val = i & 0xff
31 else:
32 val = 255 - (i & 0xff)
33 np[j] = (val, 0, 0)
34 np.write()
35
36 # clear
37 for i in range(n):
38 np[i] = (0, 0, 0)
39 np.write()
40
41
42 while True:
43 demo(np)