Working with Seven Segment LED Display
This is s a quick introduction to the basics of using seven segment LED displays with microcontrollers. Be sure to refer to the manufacturer's data sheets for more information about the devices mentioned in this tutorial.
Structure and operation of a seven segment LED display
Figure 1 shows a seven segment LED display. As indicated by the diode equivalent circuit on the left, each segment is an individual LED. This is a Common Cathode (CC) display. All of the cathodes (or negative terminals) of the segment LEDs are connected together.
To turn on a segment, you set its associated pin to HIGH (figure 2).
Figure 1: Seven segment common cathode display.
Figure 2: CC display, segment pins b and c set to HIGH
In a Common Anode (CA) seven segment display (figure 3) the anodes (positive terminals) of all of the segments are connected together.
Figure 3: Seven segment common anode display
Figure 4: CA display, segment pins b and c set to LOW.
To turn on a segment, you set its associated pin to LOW.
The resistors in the above figures limit the current through each segment to no more than the specified maximum forward current (If).
Part list:
Working with 7-Segment LEDs without Arduino
(1) Arduino Uno R3
(2) Display 7-Segment Red
(20) 220Ω Carbon Film Resistor
(10) 10kΩ Carbon Film Resistor
(10) General Purpose Transistor
(1) 9V Battery Snap
(1) 9V Alkaline Battery
(1) 830-Point Solderless Breadboard
(1) 70-Piece Jumper Wire Kit
(1) BCD to 7 Segment Latch decoder Driver
Interfacing microcontrollers and seven segment displays
Figure 5 shows a common cathode seven segment display connected to an Arduino Uno single board computer (SBC). You will need a USB-A to B cable to program the Arduino.
Figure 5: Arduino Uno connected to seven segment display.
It requires 7 digital I/O pins to drive the segments, 8 if the decimal point is included.

Figure 5a: Arduino with seven segment display output
The example code shown in Listing 1 repeatedly displays the digits 0-9 and the decimal point. The main loop calls the function DisplayDigit to display the next number. Function DisplayDigit gets the seven segment pattern for the digit and sets the segment pins accordingly.





