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

Traffic Light System with 7-Segment Countdown | Arduino | MakeMindz
Beginner+ ⏱ ~50 min 🔴 Traffic Light 🖥 Tinkercad

Traffic Light System
with 7-Segment Countdown

Combine three LEDs and a 7-segment display to build a real traffic light that counts down 5–0 for each phase — exactly like the signals on the road.

Section 01

What Will You Build?

This project combines a 7-segment display (showing digits 0–5) with a three-LED traffic light. Instead of a plain delay(5000), the display counts down from 5 to 0 during each phase — exactly how real smart traffic signals work!

🏁 What you'll learn:
💡Control multiple LEDs with digital output pins
🔢Drive a 7-segment display for a countdown
🔄Sequence events with loops and timing
🎛Use a 2D array to store segment patterns
Section 02

Traffic Light Phases

The traffic light cycles through three phases. During each, the 7-segment display counts down from 5 to 0, giving drivers and pedestrians a visual timer.

🔴 RED — Stop

Red LED ON. All traffic must stop. Display counts 5→0.

5s

🟡 YELLOW — Caution

Yellow LED ON. Traffic prepares to move. Display counts 5→0.

5s

🟢 GREEN — Go

Green LED ON. Traffic moves. Display counts 5→0.

5s
Section 03

Components Required

#ComponentQtyRole
1Arduino UNO×1Controls all LEDs and the 7-segment display
2Red LED×1Stop signal
3Yellow LED×1Caution signal
4Green LED×1Go signal
5Common Cathode 7-Segment Display×1Countdown timer (5→0) for each phase
6220Ω Resistors×107 for segments + 3 for LEDs
7Breadboard×1Clean prototyping surface
8Jumper Wires~20All connections
Section 04

Interactive Preview

Watch the traffic light and countdown work together. Press Play to start the simulation.

Live Traffic Light + 7-Segment Countdown
SIGNAL
● READY
Press Play to start
5
seconds
COUNTDOWN
Section 05

Circuit Connections

The full circuit combines three LED connections and seven 7-segment pins. Follow the wiring guide below.

Traffic light with 7-segment countdown display circuit diagram using Arduino UNO
🔴🟡🟢 Traffic Light LEDs (via 220Ω resistors)
Red LED +Digital Pin 2 on Arduino
Yellow LED +Digital Pin 3 on Arduino
Green LED +Digital Pin 4 on Arduino
All LED (–)GND on Arduino (via 220Ω resistors)
🔢 7-Segment Segments (via 220Ω resistors)
a
↓ 220Ω
Pin 7
b
↓ 220Ω
Pin 8
c
↓ 220Ω
Pin 9
d
↓ 220Ω
Pin 10
e
↓ 220Ω
Pin 11
f
↓ 220Ω
Pin 12
g
↓ 220Ω
Pin 13
COM (both)GND on Arduino
Section 06

7-Segment Display Explorer

This project only uses digits 0–5 for the countdown. Click each to see the exact segment pattern light up.

Click a digit — Common Cathode Display

Digit-by-Digit Pin States

Traffic light circuit closeup — left view Traffic light circuit closeup — right view 7-segment display showing digit 2 with active segments highlighted 7-segment display showing digit 3 with active segments highlighted
7-segment display showing digit 4 with active segments highlighted 7-segment display showing digit 5 with active segments highlighted
Section 07

Segment Truth Table (Digits 0–5)

1 = HIGH (ON)  ·  0 = LOW (OFF)  ·  Only digits 0–5 are needed for the countdown timer.

Digita (7)b (8)c (9)d (10)e (11)f (12)g (13)
Section 08

The Arduino Code

Two tabs below: the full traffic light + countdown code, and the standalone showDigit() function you can study separately.

traffic_light_7seg.ino
// ── Traffic Light + 7-Segment Countdown ──────

// Traffic Light LED Pins
int redLED    = 2;
int yellowLED = 3;
int greenLED  = 4;

// 7-Segment Pins (a–g)
int a=7, b=8, c=9, d=10, e=11, f=12, g=13;

void setup() {
  pinMode(redLED,    OUTPUT);
  pinMode(yellowLED, OUTPUT);
  pinMode(greenLED,  OUTPUT);
  pinMode(a,OUTPUT); pinMode(b,OUTPUT); pinMode(c,OUTPUT);
  pinMode(d,OUTPUT); pinMode(e,OUTPUT); pinMode(f,OUTPUT);
  pinMode(g,OUTPUT);
}

// Display a digit (0–5) on the 7-segment display
void showDigit(int num) {
  int seg[6][7] = {
    {1,1,1,1,1,1,0},  // 0: a,b,c,d,e,f ON
    {0,1,1,0,0,0,0},  // 1: b,c ON
    {1,1,0,1,1,0,1},  // 2: a,b,d,e,g ON
    {1,1,1,1,0,0,1},  // 3: a,b,c,d,g ON
    {0,1,1,0,0,1,1},  // 4: b,c,f,g ON
    {1,0,1,1,0,1,1}   // 5: a,c,d,f,g ON
  };
  digitalWrite(a, seg[num][0]);
  digitalWrite(b, seg[num][1]);
  digitalWrite(c, seg[num][2]);
  digitalWrite(d, seg[num][3]);
  digitalWrite(e, seg[num][4]);
  digitalWrite(f, seg[num][5]);
  digitalWrite(g, seg[num][6]);
}

// Countdown 5→0, one second per digit
void countdown() {
  for (int i = 5; i >= 0; i--) {
    showDigit(i);
    delay(1000);
  }
}

void loop() {
  // ── RED PHASE ──────────────────────────────
  digitalWrite(redLED,    HIGH);
  digitalWrite(yellowLED, LOW);
  digitalWrite(greenLED,  LOW);
  countdown();

  // ── YELLOW PHASE ───────────────────────────
  digitalWrite(redLED,    LOW);
  digitalWrite(yellowLED, HIGH);
  digitalWrite(greenLED,  LOW);
  countdown();

  // ── GREEN PHASE ────────────────────────────
  digitalWrite(redLED,    LOW);
  digitalWrite(yellowLED, LOW);
  digitalWrite(greenLED,  HIGH);
  countdown();
}
showDigit() — standalone
// Standalone showDigit() — drop into any project
int a=7, b=8, c=9, d=10, e=11, f=12, g=13;

void showDigit(int num) {
  int seg[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}
  };
  digitalWrite(a,seg[num][0]); digitalWrite(b,seg[num][1]);
  digitalWrite(c,seg[num][2]); digitalWrite(d,seg[num][3]);
  digitalWrite(e,seg[num][4]); digitalWrite(f,seg[num][5]);
  digitalWrite(g,seg[num][6]);
}

// Usage: showDigit(3); → displays "3" on the display
💡 Key code concepts in this project:
  • 2D arrayseg[6][7] stores all 6 segment patterns in one compact structure
  • Function reusecountdown() is called once per phase instead of repeating 18 lines
  • for loop — counts from 5 down to 0, displaying each digit and waiting 1 second
Section 09

Try It in Tinkercad

The complete circuit with traffic light LEDs and 7-segment countdown is pre-wired. Hit Start Simulation to watch the full cycle run.

Open Traffic Light Simulation

All LEDs and 7-segment display are connected. Start the simulation and watch the full RED→YELLOW→GREEN cycle with live countdown.

▶ Launch Simulator ↗
🧪 Simulator challenges:
  1. Run the simulation — observe the full RED→YELLOW→GREEN cycle with countdown.
  2. Change the for loop to count from 9→0 for a 9-second phase.
  3. Make the yellow phase shorter (count from 2→0 instead of 5→0).
  4. Challenge: Add a buzzer that beeps once per second during the red phase only.
  5. Bonus: Add a second set of traffic lights for cross-traffic!
Section 10

Test Your Knowledge

Click an option to check your answer instantly.

Q1. What does the countdown() function do in this project?
Changes the LED colour
Displays 5→0 on the 7-segment display, one per second
Reads sensor values from A0
Q2. Why is countdown() called as a function rather than repeating the code 3 times?
To make the code run faster
To avoid repeating the same code 3 times (reusability)
Because the 7-segment display requires functions
Q3. How many total digital pins does this project use on the Arduino?
3 pins
7 pins
10 pins (3 LEDs + 7 segments)
Q4. What is stored in the seg[6][7] 2D array?
The Arduino pin numbers for each segment
The HIGH/LOW pattern for each segment of digits 0–5
The colour of each traffic light phase
Section 11

Real-World Applications

🚦Smart JunctionsCountdown timers on real traffic signals
🏗School CrossingsSafe pedestrian crossing systems
🚜Factory FloorsMachine status signals with timers
🎯Game Show TimersVisual countdown for competitions
🚫Access ControlDoor wait timer with signal
🔬Science FairEye-catching exhibition project
🚀 Ready to level up? Try these extensions:
  • Add a buzzer that beeps every second during the countdown
  • Use a push button to let pedestrians manually trigger the green phase
  • Add a second 7-segment display for two-digit countdown (00–59)
  • Use a PIR motion sensor to extend green when vehicles are detected
  • Add an LCD screen showing STOP / CAUTION / GO text alongside the lights

Comments

try for free