14-Segment Alphanumeric Display

CircuitPython Code

The 14 segment alphanumeric display is demonstrated in the alphanum4_test.py script in the examples folder. If you run this example it will scroll a text message across the display. The message if followed by a run down of various integer, decimal, hex and character values. This display is great for showing complete text messages because the 14 segment displays are very flexible.

With the 14 segment display the usage is very similar to the 7 segment display above.

import time
import board
import busio
from adafruit_ht16k33 import segments

# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)

# Create the LED segment class.
# This creates a 14 segment 4 character display:
display = segments.Seg14x4(i2c)

# Clear the display.
display.fill(0)

# set brightness, range 0-1.0, 1.0 max brightness
display.brightness = 1.0

# show phrase on alphanumeric display
message = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
count = 0

# print one character at time with short sleep
# creates smooth scrolling effect
while count < len(message):
    display.print(message[count])
    count += 1
    time.sleep(0.3)

# Can just print a number
display.print(42)
time.sleep(1)

# Set the first character to '1':
display[0] = '1'
# Set the second character to '2':
display[1] = '2'
# Set the third character to 'A':
display[2] = 'A'
# Set the forth character to 'B':
display[3] = 'B'
time.sleep(1)

numbers = [0.0, 1.0, -1.0, 0.55, -0.55, 10.23, -10.2, 100.5, -100.5]

# print negative and positive floating point numbers
for i in numbers:
    display.print(i)
    time.sleep(0.5)

# print hex values, enable colon
for i in range(0xFF):
    display.fill(0)
    display.print(':')
    display.print(hex(i))
    time.sleep(0.25)

Download and Run the Code

We can easily copy this code onto our Pi's home directory using the 'wget' command and then run it using the following commands.

Download: file
cd
wget https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/Matrix_7-Segment_LED_Backpack_Raspberry_Pi/alphanum4_test.py
python3 alphanum4_test.py
This guide was first published on Aug 24, 2012. It was last updated on Aug 24, 2012. This page (14-Segment Alphanumeric Display) was last updated on Apr 01, 2020.