Skip to content

Commit c5fdf47

Browse files
committed
Added LED matrix example
1 parent 5024694 commit c5fdf47

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
# Write an 8x8 Red/Green LED matrix
3+
# https://www.adafruit.com/product/902
4+
5+
import smbus
6+
import time
7+
bus = smbus.SMBus(1)
8+
matrix = 0x70
9+
10+
delay = 1; # Delay between images in s
11+
12+
bus.write_byte_data(matrix, 0x21, 0) # Start oscillator (p10)
13+
bus.write_byte_data(matrix, 0x81, 0) # Disp on, blink off (p11)
14+
bus.write_byte_data(matrix, 0xe7, 0) # Full brightness (page 15)
15+
16+
# The first byte is GREEN, the second is RED.
17+
smile = [0x00, 0x3c, 0x00, 0x42, 0x28, 0x89, 0x04, 0x85,
18+
0x04, 0x85, 0x28, 0x89, 0x00, 0x42, 0x00, 0x3c
19+
]
20+
frown = [0x3c, 0x00, 0x42, 0x00, 0x85, 0x20, 0x89, 0x00,
21+
0x89, 0x00, 0x85, 0x20, 0x42, 0x00, 0x3c, 0x00
22+
]
23+
neutral = [0x3c, 0x3c, 0x42, 0x42, 0xa9, 0xa9, 0x89, 0x89,
24+
0x89, 0x89, 0xa9, 0xa9, 0x42, 0x42, 0x3c, 0x3c
25+
]
26+
27+
bus.write_i2c_block_data(matrix, 0, frown)
28+
time.sleep(delay)
29+
30+
bus.write_i2c_block_data(matrix, 0, neutral)
31+
time.sleep(delay)
32+
33+
bus.write_i2c_block_data(matrix, 0, smile)

0 commit comments

Comments
 (0)