Home / Learn Embedded C / Project: Debounced Counter with a 7-Segment Display
Project: Debounced Counter with a 7-Segment Display
Count button presses and show the running total on a 7-segment display.
Theory in plain words
Definition
A button-press counter (0-9) displayed on a 7-segment display, combining debouncing, a lookup table, and digital output into a complete, practical mini-project.
Why you need this
Real projects are where embedded C patterns become habits instead of theory.
How it works
Work through the steps in order; do not skip the checklist.
Where you'll see this
- Portfolio project
- Interview preparation
- Real hardware practice
What you will build
A button-press counter (0-9) displayed on a 7-segment display, combining debouncing, a lookup table, and digital output into a complete, practical mini-project.
| Level | Time needed |
|---|---|
| Intermediate | 2-3 hours |
What you need (tools and setup)
| Tool | What it is | Why you need it | Cost |
|---|---|---|---|
| This course's live C sandbox | A small in-browser C interpreter with simulated GPIO/UART/ADC/PWM. | Every project in this course can be tried here first with zero setup, no board required. | free, built in |
| Code editor (VS Code or similar) | The program you write firmware source files in. | You need somewhere to write and organise the real .c/.h files for the project. | free |
| A real development board (Arduino/AVR, STM32 Nucleo, or ESP32 dev board) — optional | The actual microcontroller hardware. | Lets you move from the simulated board to a real one once the logic works here. | low cost, optional |
| A serial terminal (PuTTY, screen, minicom, or the Arduino IDE's monitor) — optional | Shows UART text your firmware prints, from a real board. | Mirrors the UART line you already see in this course's virtual board. | free |
Step 1: see it working in the sandbox
Each simulated press increments count (wrapping at 10) and looks up the matching segment pattern to display.
Step by step
- Wire a push button (debounced, per the GPIO group) and a 7-segment display.
- Build the segment lookup table for digits 0-9.
- On each confirmed, debounced press, increment count (wrapping from 9 back to 0).
- Write the looked-up segment pattern out to the display's GPIO pins.
- Optionally also print the count over UART for easy test verification.
Checklist before you call it done
| Check | Why it matters | How to verify |
|---|---|---|
| Count wraps correctly from 9 back to 0 | Confirms the modulo wrap-around logic | Press past 9 and check it returns to 0 |
| Display always matches the printed count | Confirms the lookup table is correct and complete | Compare UART output against the physical display |
| No double-counts from a single press | Confirms debounce is actually working | Press slowly and quickly, compare counts |
A real display project needs to decide this wrap behavior explicitly, instead of letting the segment lookup index run out of bounds.
Test what you just read
1. Why does this project use a lookup table instead of computing each digit's segment pattern live?
A fixed, small set of known input-to-output mappings (digits 0-9 to their segment patterns) is the classic, ideal use case for a lookup table.