-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample4.py
60 lines (51 loc) · 886 Bytes
/
example4.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
import matrix
import urandom
import time
#assign randint function to r
r = urandom.randint
#create matrix class object
s = matrix.matrix
#initialize led matrix
s.init()
#clear led matrix
s.clear_all()
#show changes
s.show()
#smile pixmaps
smile0 = [
0,0,0,0,0,
0,1,0,1,0,
0,0,0,0,0,
1,0,0,0,1,
0,1,1,1,0
]
smile1 = [
0,0,0,0,0,
0,1,0,1,0,
0,0,0,0,0,
1,1,1,1,1,
0,0,0,0,0
]
smile2 = [
0,0,0,0,0,
0,1,0,1,0,
0,0,0,0,0,
0,1,1,1,0,
1,0,0,0,1
]
while 1:
#set random active color
s.pixel_color( r(0,360) )
#write smile pixmap to led matrix and show changes
s.clear_all()
s.pixel_mask( smile0 )
s.show()
time.sleep_ms(1000)
s.clear_all()
s.pixel_mask( smile1 )
s.show()
time.sleep_ms(1000)
s.clear_all()
s.pixel_mask( smile2 )
s.show()
time.sleep_ms(1000)