Author: Malte Bublitz
Language/File type: Python 3
Code
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
"""LED-Matrix.
"""
import time
from random import randint
from machine import Pin
from neopixel import NeoPixel
COLOR_WHITE = [255, 255, 255]
COLOR_BLACK = [0, 0, 0]
COLOR_RED = [255, 0, 0]
COLOR_GREEN = [0, 255, 0]
COLOR_BLUE = [0, 0, 255]
COLOR_YELLOW = [255, 255, 0]
COLOR_CYAN = [0, 255, 255]
COLOR_MAGENTA = [255, 0, 255]
def main():
np = NeoPixel(Pin(14), 256)
"""np.fill(COLOR_GREEN)
np.write()
time.sleep(1)
np.fill(COLOR_BLACK)
np.write()
time.sleep(1)
np[0] = COLOR_RED
np[1] = COLOR_WHITE
np[80] = [255, 255, 0]
np[42] = COLOR_CYAN
np.write()
time.sleep(1)"""
for i in range(255):
# np[i] = COLOR_RED
np[i] = [randint(0, 256), randint(0, 256), randint(0, 256)]
np.write()
time.sleep(0.01)
# np[i] = COLOR_BLACK
# np.write()
# for i in reversed(range(255)):
for i in range(255, -1, -1):
# print(i)
np[i] = COLOR_BLACK
np.write()
time.sleep(0.01)
if __name__ == "__main__":
for i in range(5):
main()