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:
| Segment | Arduino Pin |
|---|---|
| a | 7 |
| b | 8 |
| c | 9 |
| d | 10 |
| e | 11 |
| f | 12 |
| g | 13 |
-
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
| LED | Arduino Pin |
|---|---|
| Red | 2 |
| Yellow | 3 |
| Green | 4 |
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
-
The 7-segment display lights specific segments to form numbers.
-
Arrays store segment patterns for numbers.
-
Traffic LEDs change states.
-
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 :
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)
- Ultrasonic Distance Measurement
- Traffic Light Simulation with 7-Segment Display
- 7-Segment Display Counter
- Kids Piano Circuit (8-Key Version)
- 16×2 LCD Display with Text Output
- LCD I2C to Arduino UNO
- Temperature Measurement using Arduino UNO
- LDR Controlled Street Light
INTERMEDIATE PROJECTS (Build Your Skills)
- Servo Motor Control Using Potentiometer
- DC Motor Speed Control
- Temperature Controlled Fan
- PIR Based Theft Alert System
- LPG Gas Leakage Detection System
- Automatic Door Locking System
- Soil Moisture Based Automatic Watering System
- Simple Digital Clock using Arduino UNO
- Automatic Voting Machine (EVM)
- Joystick Control using Arduino Uno
- RGB Lamp Control using Arduino Uno
ADVANCED PROJECTS (Master Level)
- Home Automation Using Arduino UNO
- Bluetooth RC Car using Arduino Uno
- Obstacle Avoiding Robot
- Line Follower Robot
- Radar System Using Arduino UNO
- Automatic Parking System
- Bi-Directional People Counter using Arduino Uno
- Automatic Plant Watering System
- NeoPixel LED Ring Control using Arduino Uno
- Smart Gloves for Bedridden People


Comments
Post a Comment