User avatar
moallen
Posts: 36
Joined: Fri Dec 28, 2012 6:37 pm
Contact: Website

4 Digit 7 Segment Display - I2C Interface

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/

webdirector
Posts: 18
Joined: Wed Jan 02, 2013 1:35 am

Re: 4 Digit 7 Segment Display - I2C Interface

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

User avatar
Douglas6
Posts: 4007
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: 4 Digit 7 Segment Display - I2C Interface

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.

webdirector
Posts: 18
Joined: Wed Jan 02, 2013 1:35 am

Re: 4 Digit 7 Segment Display - I2C Interface

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,

dAm2K
Posts: 2
Joined: Wed Mar 19, 2014 9:26 pm

Re: 4 Digit 7 Segment Display - I2C Interface

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/adaf ... y-pi-in-c/

Ciao, Dino Ciuffetti.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 21 guests