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.

The short versionCount 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.

LevelTime needed
Intermediate2-3 hours

What you need (tools and setup)

ToolWhat it isWhy you need itCost
This course's live C sandboxA 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) — optionalThe 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) — optionalShows 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

Counting presses and looking up the matching segment patternC: edit and run

Each simulated press increments count (wrapping at 10) and looks up the matching segment pattern to display.

Step by step

  1. Wire a push button (debounced, per the GPIO group) and a 7-segment display.
  2. Build the segment lookup table for digits 0-9.
  3. On each confirmed, debounced press, increment count (wrapping from 9 back to 0).
  4. Write the looked-up segment pattern out to the display's GPIO pins.
  5. Optionally also print the count over UART for easy test verification.

Checklist before you call it done

CheckWhy it mattersHow to verify
Count wraps correctly from 9 back to 0Confirms the modulo wrap-around logicPress past 9 and check it returns to 0
Display always matches the printed countConfirms the lookup table is correct and completeCompare UART output against the physical display
No double-counts from a single pressConfirms debounce is actually workingPress slowly and quickly, compare counts
Tip:Commit the first working version and every later improvement as separate commits, so the diff itself becomes a teaching example.
Resetting the counter after it wraps past 9C: edit and run

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?