Interfacing of seven segment display with Arduino

In this article, We’ll learn about 7-segment displays and how the Arduino 7-segment Display Interface works.Displaying information is one of the crucial steps in electronic projects. So using a 7-segment Display has always been one of the most popular ways to display information used with an Arduino or any other microcontroller.

 Perhaps you don’t think seven-segment displays are stylish enough, yet they are the most practical way to display numbers. They are simple to use, cost-effective, and highly readable in both low and high light circumstances.

7 segment displays are used in devices like washing machines and microwave ovens to display information like quantity and time. Their low cost and easy interface are the major reasons behind this.

What is a 7-Segment Display?

Seven-segments are practical, efficient, and cost-effective devices that are used to display alphanumeric numbers. A 7-segment display is just a group of seven LEDs connected together, each of which is referred to as a segment. They can all be controlled separately.

A 7-segment device has seven light emitting diodes, as the name suggests. With a certain pattern, these light-emitting diodes are stacked and packed inside a single display. A seven-segment device will display a unique number if this pattern is controlled in a specific way by turning on and off LEDs. On a seven-segment display, there is also an extra eighth LED that is used to display dots. When displaying a fractional figure, this dot is sometimes utilised as a decimal point.

7 Segment Display Pinout

Let’s have a look at the segment arrangement to see which pins light up which segments. The 7-segment display’s pinout is as follows.

DP & a-g: The 8 pins a, b, c, d, e, f, g, and the DP segment (decimal point) are connected to Arduino’s digital pins. Numbers can be displayed by controlling each LED on the segment connected.

COM Pins:  3 and 8 are linked internally to form a single pin. Depending on the type of display, this pin should be connected to GND (common cathode) or 5V (common anode).

Types of Seven Segment Displays 

There are two 7-segment LED display configurations,

  1. Common Cathode
  2. Common Anode
Common anode and Common cathode type seven segment animation

Both varieties have essentially identical internal structures. The polarity of the LEDs and the common terminal are the differences. The common cathode has all of the LEDs’ cathodes connected together in a 7-segment, whereas the common anode has all of the LEDs’ anodes connected together in a 7-segment.

The only difference in the interface of common anode and common cathode type 7-segment displays is the use of common pins. Connect Arduino’s 5-volt pin to common pins 3 or 8 for common anode type. Connect common pins 3 or 8 to Arduino’s ground pin for the common cathode type.

Common Anode Display

All of the anodes terminals of eight light emitting diodes are connected to a 5 volt power supply in a common anode display. We apply logic high from Arduino to each section in typical conditions. As a result, each segment is either turned off or does not illuminate. Similarly, we supply logic low signal to turn on a single LED of a seven-segment gadget. Because, in the case of a common anode type display, LEDs only glow when there is a logic high signal on the anode side and a logic low signal on the cathode side.

Common Cathode Display

All of the cathodes of eight light emitting diodes are connected to the ground in a common cathode segment display. We apply logic low from Arduino to any segment of the 7-segment in order to turn it off. Similarly, we provide a logic high signal from an Arduino digital output pin to turn on a specific LED of a seven-segment device. Because, in the case of a common cathode type display, LEDs only glow when there is a logic high signal on the anode side and a logic low signal on the cathode side.

How does it work?

Before we connect the 7-segment display to an Arduino, let’s have a look at its features and usefulness.

Seven LEDs are lined up in a certain way on the 7-segment displays. In this example, it’s the well-known number ‘8’ shape. Each of the seven LEDs is referred to as a segment because when illuminated, it forms part of a numerical digit (both decimal and hexadecimal) that will be shown. A decimal point is occasionally indicated with an additional 8th LED.

Each of the display’s seven LEDs is assigned a positional segment, with one of its connecting pins protruding from the rectangular plastic container. Individual LED pins are labeled with letters a through g to symbolise each LED. The remaining LED pins are linked together to produce a single pin.

You set the relevant pin HIGH or LOW to turn on and off a specific section of the display, just like you would with a standard LED. As a result, some segments will be light and others will be dark, allowing the display to form the required character pattern of the number. This allows us to see each of the ten decimal digits, from 0 to 9.

Interfacing 7-segment Display with Arduino

  • Between the LED pins and the Arduino digital I/O pins, you must connect the resistors. 
  • The brightness of the LEDs can be increased or decreased by adjusting the value of these resistors.
  • The LED pins can be connected to any of the Arduino’s digital I/O pins.
  • It’s critical to know whether your segment is a common cathode or a common anode. A datasheet can be used to cross-check.
  • If you’re using the common cathode version, you’ll need to activate the matching section by sending a LOW signal to the drive pin.
  • If you’re using the common anode version, you’ll need to activate the matching section by sending a HIGH signal to the drive pin.

Each LED in the 7-segment display is linked to GPIO pins on the Arduino board separately. Consider a 7-segment common anode (CA) display for interface purposes.Because the anode is the common terminal, we’ll connect it to the Arduino’s 5V supply. The rest of the pins will be connected to the Arduino’s GPIO pins.

Truth Table for 7-Segment Display

Code for turning ON all the LEDs one by one

void setup()
// define pins as an output pins



void loop()
// loop to turn on the led

for(int i=2;i<9;i++)

// loop to turn on the led
for(int i=2;i<9;i++)



Code for displaying digits/numbers

// make an array to save Sev Seg pin configuration of numbers

int num_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0
{ 0,1,1,0,0,0,0 }, // 1
{ 1,1,0,1,1,0,1 }, // 2
{ 1,1,1,1,0,0,1 }, // 3
{ 0,1,1,0,0,1,1 }, // 4
{ 1,0,1,1,0,1,1 }, // 5
{ 1,0,1,1,1,1,1 }, // 6
{ 1,1,1,0,0,0,0 }, // 7
{ 1,1,1,1,1,1,1 }, // 8
{ 1,1,1,0,0,1,1 }}; // 9

//function header
void Num_Write(int);

void setup()
// set pin modes
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);


void loop()

//counter loop

for (int counter = 10; counter > 0; –counter)

// this functions writes values to the sev seg pins
void Num_Write(int number)
int pin= 2;
for (int j=0; j < 7; j++) {
digitalWrite(pin, num_array[number][j]);

Applications of a seven-segment display

  • Useful in designing counters and displaying the counts.
  • It is not dependent on a microcontroller. As a result, it’s suitable for minor jobs.
  • It also features a brilliant illumination. As a result, it is useful in both light and dark situations.
  • Digital clocks, calculators, and wristwatches all benefit from this feature.
  • Also useful in speedometers and odometers.
  • Mainly it helps to display the data that are created by many devices.

Leave a Reply

Your email address will not be published.