7-Segment Display
with Arduino UNO
Learn to light up individual LED segments to display digits 0–9. Understand the binary logic behind every digital clock ever made.
What Are We Building?
A 7-segment display is exactly what it sounds like — 7 individual LED segments (labeled a through g) arranged like a figure-8. By turning specific segments HIGH or LOW, we can display any digit from 0 to 9. The Arduino controls each segment pin directly, giving us full control over what number appears.
Digital Output
Control 7 individual pins using digitalWrite() to switch LEDs on/off.
LED Segment Logic
Understand how a specific combination of segments makes each digit.
Number Display
Translate a digit (like 5) into a pattern of HIGH/LOW pin states.
Embedded Programming
Write structured, readable Arduino code using setup() and loop().
What You Need
| # | Component | Qty | Role |
|---|---|---|---|
| 1 | Arduino UNO | ×1 | Controls which segments are ON or OFF |
| 2 | Common Cathode 7-Segment Display | ×1 | Displays digits 0–9 using 7 LED segments |
| 3 | 220Ω Resistors | ×7 | One per segment — protects LEDs from excess current |
| 4 | Breadboard | ×1 | Prototyping platform for clean connections |
| 5 | Jumper Wires | ×~12 | Connect display pins to Arduino through resistors |
⚠️ Common Cathode vs Common Anode: In Common Cathode, all LED negatives share GND and you set segment pins HIGH to light them. In Common Anode (opposite), all positives share 5V and you set pins LOW to light them. Tinkercad uses Common Cathode by default.
Tap a Digit to See Its Segments
Each number uses a unique combination of segments. Tap any digit below to see which segments light up — and which pins go HIGH.
7-Segment Display — Common Cathode
Wiring It All Together
🔌 Segment Pins → Arduino (via 220Ω resistors)
⚡ Power & Ground
💡 Why 220Ω on each segment? Each segment is an LED. Without a resistor, too much current flows and the LED burns out. With 220Ω, the current is limited to a safe ~10–15mA — bright enough to see, safe for both the LED and Arduino pin.
Which Segments Light Up for Each Digit?
1 = HIGH (segment ON) 0 = LOW (segment OFF). Each row is a digit, each column is a segment pin.
| Digit | a (7) | b (8) | c (9) | d (10) | e (11) | f (12) | g (13) |
|---|
The Program
This code displays the digit 0 on the 7-segment display. Segments a–f are set HIGH, segment g (the middle bar) stays LOW.
// ── Segment Pin Definitions ─────────────────── int a = 7; // Top horizontal int b = 8; // Top-right vertical int c = 9; // Bottom-right vertical int d = 10; // Bottom horizontal int e = 11; // Bottom-left vertical int f = 12; // Top-left vertical int g = 13; // Middle horizontal 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() { // Display 0 → segments a, b, c, d, e, f ON; g OFF digitalWrite(a, HIGH); // top bar ── ON digitalWrite(b, HIGH); // top-right │ ON digitalWrite(c, HIGH); // bot-right │ ON digitalWrite(d, HIGH); // bot bar ── ON digitalWrite(e, HIGH); // bot-left │ ON digitalWrite(f, HIGH); // top-left │ ON digitalWrite(g, LOW); // middle ── OFF delay(1000); }
Once you understand individual digit display, the next step is to cycle through all 10 digits automatically. Store each digit's segment pattern in an array and loop through them with a counter. Try this after completing the basic project!
Simulate Before You Build
The full circuit is pre-wired in Tinkercad. Hit Start Simulation and watch the digit appear — then edit the code to try other numbers.
Open in Tinkercad Simulator
All 7 segments are wired up with resistors. Start simulation, then modify the digitalWrite() values to display different digits.
- Start simulation — confirm the digit 0 appears on the display.
- Use the truth table above to modify the code to display digit 5.
- Add a
delay(1000)and write code to display digits 0 then 1 then 2 in sequence. - Challenge: Display all 10 digits from 0 to 9 automatically, one per second.
- Bonus: What happens when you set ALL segments HIGH? (Displays 8!)
Quick Quiz
Tap an option to check your answer instantly.
Q1. How many LED segments does a standard 7-segment display have?
Q2. In a Common Cathode display, which pin is connected to GND?
Q3. To display the digit "1", which segments should be ON?
Q4. Why is a 220Ω resistor placed on each segment pin?
Where Is This Used?
- Build an automatic counter that counts 0→9 and loops back
- Add a push button to increment the count manually
- Use two displays to show two-digit numbers (00–99)
- Combine with a PIR sensor to build an automatic visitor counter
- Use the 74HC4511 BCD decoder to control the display with only 4 pins
Comments
Post a Comment