Back to: Robotics & Artificial Intelligence (Class IX)
In this module, you will learn how to interface a seven-segment display with an Arduino to display digits. You will understand how to control the individual segments of the display to form numbers and other characters. This will introduce you to the concept of multiplexing and controlling outputs in Arduino.
Components Required:
- 1 x Arduino Uno
- 1 x Seven-Segment Display (Common Cathode or Common Anode)
- 7 x 220-ohm resistors
- Jumper wires
- Breadboard
- USB Cable (to connect Arduino to PC)
Circuit Diagram:
- Seven-Segment Display Pins: The seven-segment display has 8 segments (A, B, C, D, E, F, G, and the decimal point). Each segment is controlled individually.
- Common Pin: Depending on whether you are using a Common Cathode or Common Anode display, connect the common pin either to GND or VCC.
- Resistors: Connect 220-ohm resistors in series with each segment to limit the current.
- Arduino Pins: Connect the corresponding segments of the display to Arduino digital pins (choose pins 3 through 9 for the 7 segments).
Step-by-Step Guide:
Step 1: Wiring the Circuit

- Place the seven-segment display on the breadboard.
- Connect each segment (A, B, C, D, E, F, G) to digital pins 3 through 9 of the Arduino.
- Use a 220-ohm resistor for each segment to limit the current and avoid damage to the display.
- Connect the common pin of the display to GND (for common cathode) or VCC (for common anode).
- If you’re using a display with a decimal point, you can connect that to another pin (optional).
Step 2: Writing the Arduino Code
int a=3;
int b=4;
int c=5;
int d=6;
int e=7;
int f=8;
int g=9;
void setup()
{
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
pinMode(g,OUTPUT);
}
void loop()
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
delay(1000);
}