Seven Segments… What More Could You Need?

Seven-segment displays are pretty useful tools for taking a project from indicator lamps to actual human-machine interaction. The only problem is, one digit of one display adds 7 outputs that you have to drive (or sink) and that doesn’t leave many signals for the process. How do you overcome this hurdle? Well, electronics engineers thought of that and came up with display driver IC chips. Basically, these take a more condensed set of data and deal with the overhead of controlling the display for you. For this project day, my goal was to use the least outputs possible to drive a 2-digit seven-segment display using the outputs from a microcontroller (I used Arduino Uno). Read on to see how I did.


Prototype Display Circuit

Prototype Display Circuit

For the uninitiated, a seven-segment display is just an array of LEDs arranged to form the number 8. Well, actually any light source could be used, but I’m focusing on LED displays. By choosing which of the LEDs to light, the arrangement can articulate any numeral. This technology is used pretty much anywhere cheap numbers are needed, so in digital watches, calculators, thermometers, etc. LED displays in particular come in one of two flavors, common cathode and common anode. The type is important in selecting your driver, so watch out.

Seven-Segment LED Display

Seven-Segment LED Display

My display is a two-digit display with decimal points (Avago Technologies HDSP-5621, common anode, 2.5V, 30mA per segment)

There are a number of choices when it comes to display drivers. Input types include BCD, parallel binary, and serial. The output types vary from driving particular display types like LED, LCD, CRT to driving a generic output and from one up to eight digits . The driver I had on hand was a BCD to common anode LED driver for one digit (Texas Instruments SN74LS47). Part of my goal was to use the components I had to reduce my costs, but if I were to buy a driver from scratch, I’d want to go with a two-digit common anode driver with serial input.

At this point, I could have driven all 14 LEDs from 8 inputs to the display driver ICs, but 8 pins is a lot to ask on a small microcontroller, so the only way to reduce again was to look at serial. I chose to use a simple parallel-out shift register IC (takes in serial data and a clock pulse and outputs the last 8 serial bits as parallel data). I didn’t have anything on hand, so I selected Texas Instruments SN74HC164N.

Prototyping was pretty straightforward. I selected 220Ohm resistors to limit the current between each segment and the driving IC (assuming 1.2V-2.5V drop across resistors, that would be 17mA – 11mA from my 5V source). Also, I had to choose if the serial data would come from the microcontroller as LSb first or MSb first. The choice was completely mine since I wouldn’t be able to use the Serial method in the Arduino due to the clock requirement on the shift register. I opted to stick with convention and send the LSb first.

Here is a drawing of my prototype circuit:

Schematic of Seven-Segment Display Driver

Schematic of Seven-Segment Display Driver

Here is the Arduino code I used to drive the display:

// define all constant parameters here

int LEDPin = 2;
int CLKPin = 3;
int i = 0;
int j = 0;

//Debugging settings
#define DebugBaud 9600

void setup()
// Debugging Setup

pinMode(LEDPin, OUTPUT);
pinMode(CLKPin, OUTPUT);

void loop()
//Debugging Message
// Serial.println(“Online”);

for (j = 0; j <= 9; j++){
Serial.println(” is on the display”);
Transmit((byte) j);


void Transmit(byte Msg)
for (i = 0; i <= 7; i++){
// delay(100);

void writeBit(boolean Val) {
digitalWrite(CLKPin, LOW);
// delay(1);

if (Val) {digitalWrite(LEDPin, HIGH);}
else {digitalWrite(LEDPin, LOW);}

digitalWrite(CLKPin, HIGH);

That was my project day!

If you liked this project, check out some of my others:

Integration… It’s not just about that silly ‘S’

Instant Parade!

The ThrAxis – Our Scratch-Built CNC Mill

Did you like It’s Project Day? You can subscribe to email notifications by clicking ‘Follow’ in the side bar on the right, or leave a comment below.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s