IoTSimulator

Build a 7-Segment Countdown with Arduino

Build a simple countdown timer with an Arduino Uno, a single-digit 7-segment display, a push button, and a buzzer. Press the button to count from 9 down to 0, then hear a short finish alert when the countdown ends.

Io
IoTSim Editor
May 9, 2026
Build a 7-Segment Countdown with Arduino

Live project track

Interactive hardware & logic preview

A countdown timer is easy to understand before we touch the code. Press a button, watch the number step down, and listen for a beep when the count reaches zero. That familiar flow makes this a strong beginner project because the goal is visible from the first second.

In this project, you will build a single-digit countdown timer with an Arduino Uno, a 7-segment display, a push button, and a buzzer. The main concept is: a number on a 7-segment display is really a pattern of smaller LED segments.

Each Countdown Number Is a Segment Pattern

A 7-segment display looks like one numeric display, but it is made from separate LED bars. Those bars are usually named A, B, C, D, E, F, and G. To show a number, the Arduino does not send the number directly. It turns on the exact bars that make that digit recognizable.

For example, the number 8 uses every segment. The number 1 only uses the two right-side segments. The number 0 uses almost everything except the middle segment. Once you see the display this way, the code becomes less mysterious: each digit is just an on/off recipe.

7-segment display segments forming countdown digits
7-segment display segments forming countdown digits
DigitSegments that turn onWhy it looks right
9A, B, C, D, F, GEverything except the lower-left segment
1B, COnly the two right-side bars
0A, B, C, D, E, FA full outline without the middle bar

This is why the sketch is intentionally a little long. Instead of hiding the digit patterns inside an array or helper function, it writes the segment states directly. That makes the beginner lesson more visible: number equals pattern.

One Button Starts the Whole Countdown Sequence

The push button has one job: start the countdown from 9. After the button press, the Arduino handles the rest. It shows 9, waits one second, shows 8, waits again, and keeps going until the display reaches 0.

The code uses a small memory variable called counting. When counting is true, the countdown is active and the number should decrease. When counting is false, the display waits at zero and the buzzer stays quiet.

Push button starting a 7-segment countdown sequence and finish buzzer
Push button starting a 7-segment countdown sequence and finish buzzer
The button does not count down by itself. It only tells the Arduino to begin a sequence, and the Arduino updates the display one number at a time.

The button uses INPUT_PULLUP, which means the Arduino normally reads HIGH when the button is not pressed. When the button is pressed, it connects the pin to GND and the reading becomes LOW. GND is the return path for electricity, like the negative terminal of a battery.

A Common Cathode Display Lights Segments With HIGH Signals

This project uses the display like a common cathode module. Common cathode means the shared COM pins connect to GND. With that setup, a segment turns on when its Arduino pin is set HIGH. HIGH means the pin is near 5V, so power can flow through that segment LED.

Common cathode 7-segment segment lighting from Arduino HIGH output
Common cathode 7-segment segment lighting from Arduino HIGH output
  • COM pins connect the shared side of the display to GND.
  • Segment pins connect to Arduino output pins.
  • HIGH output lights a segment in this common cathode setup.
  • LOW output turns that segment off.

Real 7-segment displays should use current-limiting resistors for the segments because each segment is an LED. The simulator keeps the wiring simple, but on a physical breadboard you should add resistors so the display and Arduino pins are protected.

Each Wire Controls One Countdown Part

The circuit has three working groups. The 7-segment display shows the countdown number. The push button starts the sequence. The buzzer gives a finish alert when the display reaches zero.

The display uses many wires because every segment is controlled separately. That is the main tradeoff of a single 7-segment display: the output is very clear, but the Arduino must control each LED bar.

Pin Connection Map
7-Segment Display
A
Arduino Uno
D2
Explanation

Controls the top segment of the digit.

7-Segment Display
B
Arduino Uno
D3
Explanation

Controls the upper-right segment.

7-Segment Display
C
Arduino Uno
D4
Explanation

Controls the lower-right segment.

7-Segment Display
D
Arduino Uno
D5
Explanation

Controls the bottom segment.

7-Segment Display
E
Arduino Uno
D6
Explanation

Controls the lower-left segment.

7-Segment Display
F
Arduino Uno
D7
Explanation

Controls the upper-left segment.

7-Segment Display
G
Arduino Uno
D8
Explanation

Controls the middle segment.

7-Segment Display
COM.1
Arduino Uno
GND
Explanation

Connects the common cathode side to ground.

7-Segment Display
COM.2
Arduino Uno
GND
Explanation

Connects the second common pin to the same ground reference.

Pin Connection Map
Push Button
Pin 1
Arduino Uno
D9
Explanation

Carries the start button signal into the Arduino.

Push Button
Pin 2
Arduino Uno
GND
Explanation

Pulls D9 LOW when the button is pressed.

Pin Connection Map
Buzzer
Positive
Arduino Uno
D10
Explanation

Receives the finish tone signal.

Buzzer
Negative
Arduino Uno
GND
Explanation

Completes the buzzer circuit back to ground.

If the display lights the wrong shape, check the segment wires first. A swapped B and C wire can make the countdown numbers look strange even when the code is correct.

The Complete 7-Segment Countdown Sketch

The sketch is longer than many beginner examples because it writes each segment directly. That is a conscious choice for learning. A shorter version could use arrays or helper functions, but this version keeps every segment decision visible.

The countdown starts when the button is pressed. The display updates once per second, and the buzzer plays a short tone after zero.

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

How the 7-Segment Countdown Code Works, Part By Part

Now let us break the sketch into smaller pieces. The code has four main jobs: name the pins, start the countdown, draw the current digit, and beep when the countdown reaches zero.

▸ Countdown Segment Pins Name Each LED Bar

The first lines name each display segment. Pin numbers are the physical Arduino connectors used by the wires. Naming the pins makes the code read like a wiring diagram.

C++ Source
1
2
3
4
5
6
7
8
9

▸ Setup Prepares Display, Button, and Buzzer

In setup(), every segment pin becomes an OUTPUT, which means the Arduino controls that pin. The button uses INPUT_PULLUP, so it normally reads HIGH and reads LOW when pressed. The buzzer pin is also an output because the Arduino sends the finish tone.

C++ Source
1
2
3
4
5
6
7
8
9
10
11

▸ Button Loads 9 as the Starting Number

When the button reads LOW, the countdown starts. The sketch sets counting to true and loads currentNumber with 9. The short pause keeps one tap from being read again immediately.

C++ Source
1
2
3
4
5

▸ Digit Blocks Light the Right Segments

The long if and else if section chooses which segment pins turn on for the current number. For digit 9, segment E is off and the other main segments are on. For digit 1, only B and C are on.

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

The full sketch includes all digits from 0 to 9. It is verbose, but it lets beginners see the exact relationship between a number and the segments that form it.

▸ Running Mode Steps Toward Zero

If counting is true, the Arduino waits one second. If the current number is not zero, it subtracts one. That repeated subtracting is what turns the display into a countdown.

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14

When the number reaches zero, the buzzer plays a short finish tone and counting becomes false. The display stays at zero until the button starts a new countdown.

Adjusting the Countdown Timing and Alert

If you want the countdown to move faster, reduce countdownDelayMs. A value of 500 makes each digit last half a second. If you want a slower timer, increase it to 1500 or 2000.

The buzzer finish alert is controlled by finishToneHz and finishBeepMs. Lower the frequency for a deeper beep, raise it for a sharper beep, and change the duration if the alert feels too short or too long.

Taking It Further

Once the countdown works, you can add a second button that resets the timer immediately. You can also connect the decimal point and blink it during the countdown as a small activity indicator.

A later version can use arrays or helper functions to make the digit patterns shorter. That is a good next step after the beginner version makes the segment logic clear.

Keywords
#Arduino #7-Segment #Countdown #Timer #Push Button #Buzzer #Beginner #Digital Output
Total word count: 1210 words

Project discussion

Questions, feedback, and community insights
No discussions yet. Be the first to start!