4 Digit 7 Segment Display - I2C Interface


5 posts
by moallen » Fri Feb 08, 2013 12:42 am
Adafruit's 4-Digit 7-Segment display with its companion HT16K33 backpack is the focus of this post. This display requires just 4 wires, including +3.3VDC and Gnd. The other 2 wires are used by its I2C interface consisting of the SDA and SCL signals.

As seen in this photo, +3.3VDC and Gnd are supplied by the Gertboard. The SDA and SCL signals are connected on the Gertboard J2 header for convenience. Otherwise, the Gertboard is not used in this test.

The display operates on a supply voltage of either 3.3VDC or 5VDC, which means it can be connected to the RPi without level conversion as long as it is powered by 3.3VDC. Its brightness can be adjusted to 16 levels by command, as well as a blink rate. The display continues to illuminate its last set of characters without an I2C connection, as long as it has power.

This short program generates random numbers and displays them. It is using Adafruit's SevenSegment module, which is part of their 'Adafruit-Raspberry-Pi-Python-Code' package, to turn on the proper segments.

seven-segment-test-1.py

Code: Select all
import time
import random
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

while True:
    segment.writeDigit(0,random.randint(0,9))
    segment.writeDigit(1,random.randint(0,9))
    segment.writeDigit(3,random.randint(0,9))
    segment.writeDigit(4,random.randint(0,9))
    time.sleep(3)


If you're curious, the 'theoretical' odds of all 4 numbers coming up the same is 1/10000.
http://allenmlab.blogspot.com/
User avatar
Posts: 36
Joined: Fri Dec 28, 2012 6:37 pm
by webdirector » Fri Nov 08, 2013 7:55 pm
Hello,

I have a project and I would need to have two 4 digit 7 segment displays in use.

Is that possible ? One would be a clock and the second would be a timer ( counting down )

So my question is is there a way to control Two displays at once ?

Thanks
Posts: 14
Joined: Wed Jan 02, 2013 1:35 am
by Douglas6 » Fri Nov 08, 2013 8:34 pm
These backpacks have 3 address lines that can be selected with solder bridges. So, yes, with a bit of careful soldering, you could use up to 8 of these.
User avatar
Posts: 488
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by webdirector » Sat Nov 09, 2013 4:49 pm
Hello

Thanks for pointing this out to me.

For others looking for this. Here is a link on how to set the address:

http://learn.adafruit.com/adafruit-led- ... 2c-address

Regards,
Posts: 14
Joined: Wed Jan 02, 2013 1:35 am
by dAm2K » Fri Apr 04, 2014 10:37 pm
Hi there. This is an old post, but I hope that can always be helpful to someone.
I created a simple userspace C library for the Adafruit 4 digit 7 segment display on raspberry pi.
It's apache v2 licensed (can be used in closed, commercial and open environments).

If you like, you can download it from here: http://dino.ciuffetti.info/2014/04/adafruit-4-digit-7-segment-backpack-raspberry-pi-in-c/

Ciao, Dino Ciuffetti.
Posts: 2
Joined: Wed Mar 19, 2014 9:26 pm