7-Segment Display to Arduino Uno in Tinkercad (With Traffic Light Counter)

 7-Segment display to Arduino in tinker cad

 Introduction

In this beginner Arduino project, we will learn how to interface a Common Cathode 7-Segment Display with the Arduino Uno using Tinkercad simulation.

We will also extend the project to create a Traffic Light System with 7-Segment Countdown Timer, which is perfect for school exhibitions.

 Components Required

  • Arduino UNO

  • Common Cathode 7-Segment Display

  • 220Ω Resistors (7)

  • Breadboard

  • Jumper wires

  • 3 LEDs (Red, Yellow, Green) – for traffic light

  • 220Ω resistors for LEDs

 Circuit Setup

Step 1: 7-Segment Connections

Connect segments (a–g) to Arduino pins:

SegmentArduino Pin
a7
b8
c9
d10
e11
f12
g13
  • Connect all through 220Ω resistors.

  • Connect both Common Cathode (COM) pins to GND.

 Always use resistors to prevent LED damage.


Step 2: Traffic Light LED Connections

LEDArduino Pin
Red2
Yellow3
Green4

 Understanding Number Display (0–5)

For Common Cathode:

  • HIGH → Segment ON

  • LOW → Segment OFF

Instead of manually writing each combination, we use arrays for simplicity.


 Arduino Code – Display Numbers 0 to 5

int segmentPins[7] = {7,8,9,10,11,12,13};

byte numbers[6][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
};

void setup() {
for(int i=0; i<7; i++){
pinMode(segmentPins[i], OUTPUT);
}
}

void displayNumber(int num){
for(int i=0; i<7; i++){
digitalWrite(segmentPins[i], numbers[num][i]);
}
}

void loop() {
for(int i=0; i<=5; i++){
displayNumber(i);
delay(1000);
}
}

 Traffic Light with 7-Segment Countdown

Now instead of using a 5-second delay, we show countdown from 5 to 0 for each signal.


 Traffic Light Code with Countdown

int red = 2;
int yellow = 3;
int green = 4;

int segmentPins[7] = {7,8,9,10,11,12,13};

byte numbers[6][7] = {
{1,1,1,1,1,1,0},
{0,1,1,0,0,0,0},
{1,1,0,1,1,0,1},
{1,1,1,1,0,0,1},
{0,1,1,0,0,1,1},
{1,0,1,1,0,1,1}
};

void setup() {
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);

for(int i=0;i<7;i++){
pinMode(segmentPins[i], OUTPUT);
}
}

void displayNumber(int num){
for(int i=0;i<7;i++){
digitalWrite(segmentPins[i], numbers[num][i]);
}
}

void countdown(){
for(int i=5;i>=0;i--){
displayNumber(i);
delay(1000);
}
}

void loop() {

digitalWrite(green, HIGH);
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
countdown();

digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
countdown();

digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
countdown();
}

 How It Works

  1. The 7-segment display lights specific segments to form numbers.

  2. Arrays store segment patterns for numbers.

  3. Traffic LEDs change states.

  4. Countdown function displays timer visually.


 Learning Outcomes

Students will learn:

  • Digital output control

  • Array usage in Arduino

  • Traffic light logic implementation

  • Countdown timer design

  • Real-world embedded system simulation


 Applications

  • Smart traffic control system

  • Digital countdown timer

  • School Arduino exhibition

  • Embedded systems beginner project

Below is the code to display the numbers on the 7 segment display.


Number 0:                            Number 1:


  • For number 0 to be displayed in the 7 segment display pins 11,10,7,8,9,12 should be high and pin 13 should be low.

  • For number 1 to be displayed in the 7 segment display pins 11,8,9,12 should be low and pin 10,7 should be high.

Number 2:                    Number 3:


  • For number 2 to be displayed in the 7 segment display pins 13,11,10,8,9, should be high and pin 7,12 should be low.

  • For number 3 to be displayed in the 7 segment display pins 11,10,7,8,13 should be low and pin 9,12 should be low.


Number 4:                             Number 5:


  • For number 4 to be displayed in the 7 segment display pins 7,10,12,13 should be high and pin 8,9,11 should be low.

  • For number 5 to be displayed in the 7 segment display pins 7,8,11,12,13 should be low and pin 10,9 should be high.

Try it in tinker cad :



7-segment display 


 Traffic light System:


Instead of having a delay of 5 seconds in the code we could replace the code for the 7 segment display to print the numbers from 0 to 5 .In order to reduce the code complexity we just depicted the code below to display numbers from 0 to 5 which could be inserted in between.


Traffic light code:



Try this in tinker cad:

Traffic light using 7 segment display

 


BEGINNER PROJECTS (Foundation Skills)

  1. Ultrasonic Distance Measurement
  2. Traffic Light Simulation with 7-Segment Display
  3. 7-Segment Display Counter
  4. Kids Piano Circuit (8-Key Version)
  5. 16×2 LCD Display with Text Output
  6. LCD I2C to Arduino UNO
  7. Temperature Measurement using Arduino UNO
  8. LDR Controlled Street Light

INTERMEDIATE PROJECTS (Build Your Skills)

  1. Servo Motor Control Using Potentiometer
  2. DC Motor Speed Control
  3. Temperature Controlled Fan
  4. PIR Based Theft Alert System
  5. LPG Gas Leakage Detection System
  6. Automatic Door Locking System
  7. Soil Moisture Based Automatic Watering System
  8. Simple Digital Clock using Arduino UNO
  9. Automatic Voting Machine (EVM)
  10. Joystick Control using Arduino Uno
  11. RGB Lamp Control using Arduino Uno

    ADVANCED PROJECTS (Master Level)

    1. Home Automation Using Arduino UNO
    2. Bluetooth RC Car using Arduino Uno
    3. Obstacle Avoiding Robot
    4. Line Follower Robot
    5. Radar System Using Arduino UNO
    6. Automatic Parking System
    7. Bi-Directional People Counter using Arduino Uno 
    8. Automatic Plant Watering System
    9. NeoPixel LED Ring Control using Arduino Uno
    10. Smart Gloves for Bedridden People

      ROBOTICS & MOTION PROJECTS

      1. RC Car Using L293D Motor Driver
      2. Robot Arm and Leg Control Using Servo
      3. Smart Irrigation System using Arduino Uno

      Comments