Skip to content

Commit 2c83e3b

Browse files
committed
Alphanumeric 14x4 scrolling text example
1 parent 88cc64a commit 2c83e3b

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import time
2+
import board
3+
import busio
4+
from adafruit_ht16k33 import segments
5+
6+
# Create the I2C interface.
7+
i2c = busio.I2C(board.SCL, board.SDA)
8+
9+
# Create the LED segment class.
10+
# This creates a 14 segment 4 character display:
11+
display = segments.Seg14x4(i2c)
12+
13+
# Clear the display.
14+
display.fill(0)
15+
16+
# set brightness, range 1-15, 15 max brightness
17+
display.brightness = 15
18+
19+
# show phrase on alphanumeric display
20+
message = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
21+
count = 0
22+
23+
# print one character at time with short sleep
24+
# creates smooth scrolling effect
25+
while count < len(message):
26+
display.print(message[count])
27+
count += 1
28+
time.sleep(0.3)
29+
30+
# Can just print a number
31+
display.print(42)
32+
time.sleep(1)
33+
34+
# Set the first character to '1':
35+
display[0] = '1'
36+
# Set the second character to '2':
37+
display[1] = '2'
38+
# Set the third character to 'A':
39+
display[2] = 'A'
40+
# Set the forth character to 'B':
41+
display[3] = 'B'
42+
time.sleep(1)
43+
44+
numbers = [0.0, 1.0, -1.0, 0.55, -0.55, 10.23, -10.2, 100.5, -100.5]
45+
46+
# print negative and positive floating point numbers
47+
for i in numbers:
48+
display.print(i)
49+
time.sleep(0.5)
50+
51+
# print hex values, enable colon
52+
for i in range(0xFF):
53+
display.fill(0)
54+
display.print(':')
55+
display.print(hex(i))
56+
time.sleep(0.25)

0 commit comments

Comments
 (0)