-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpixels.py
61 lines (48 loc) · 1.29 KB
/
pixels.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
This example shows how to use the ModulinoPixels class to control a set of pixels.
The pixels are set to different colors and animations.
You can use the ModulinoColor class to set predefined colors:
- RED, GREEN, BLUE, YELLOW, CYAN, VIOLET, WHITE
Initial author: Sebastian Romero ([email protected])
"""
from modulino import ModulinoPixels, ModulinoColor
from time import sleep
pixels = ModulinoPixels()
for index in range(0, 8):
color_wheel_colors = [
(255, 0, 0),
(255, 85, 0),
(255, 255, 0),
(0, 255, 0),
(0, 255, 255),
(0, 0, 255),
(255, 0, 255),
(255, 0, 0)
]
pixels.set_rgb(index, *color_wheel_colors[index], 100)
pixels.show()
sleep(1)
pixels.set_all_rgb(255, 0, 0, 100)
pixels.show()
sleep(1)
pixels.set_all_color(ModulinoColor.GREEN, 100)
pixels.show()
sleep(1)
pixels.set_all_color(ModulinoColor.BLUE, 100)
pixels.show()
sleep(1)
# Night Rider animation
for j in range(0, 3):
for i in range(0, 8):
pixels.clear_all()
pixels.set_rgb(i, 255, 0, 0, 100)
pixels.show()
sleep(0.05)
for i in range(7, -1, -1):
pixels.clear_all()
pixels.set_rgb(i, 255, 0, 0, 100)
pixels.show()
sleep(0.05)
# Turn off all LEDs
pixels.clear_all()
pixels.show()