ExoSynkLab

exosynk/seven-segment-counter

exosynk/seven-segment-counter

7-segment counter (0-9 on Arduino)

Seven Arduino digital pins drive a common-cathode 7-segment display. A shared 330Ω resistor limits current to ground. Code counts 0→9 in a loop.

0 views0 upvotes0 forks4 partsUpdated Apr 19, 2026, 6:30 PMCreated Apr 19, 2026

README

7-segment counter

Seven Arduino pins, one segment per pin, common cathode tied to ground through a 330Ω resistor. The code counts 0 → 9 at one digit every 600 ms.

Segment mapping

A 7-segment display has seven LEDs arranged like this:

 aaaa
f    b
f    b
 gggg
e    c
e    c
 dddd

Each segment is wired to an Arduino pin (a → d2, b → d3, ..., g → d8). The digit table in the code encodes which segments to light for each number — 3 lights a, b, c, d, g but leaves e and f dark.

One resistor or seven?

Real-world builds use one resistor per segment (7 total) so every segment has the same brightness even when different counts of segments are lit. This lab uses a single shared resistor on the cathode line for schematic simplicity — you'll see a subtle brightness difference between digits that light more segments (like 8) vs fewer (like 1). Fork this and split out seven individual resistors if you want it right.

Try this

  • Change delay(600) to 100 — fast counter, barely readable.
  • Flip the order: n = (n + 9) % 10 counts down 9 → 0.
  • Replace the digit table to draw letters: b, c, d, E, F, A. Standard hex pattern — handy for a debug display.

Common anode vs common cathode

This lab uses a common-cathode 7-seg (all cathodes tied to GND; a pin is ON when driven HIGH). Common-anode versions flip it: common pin goes to 5 V and a segment lights when the Arduino pin is LOW. Invert the writeDigit logic if you're adapting to a common-anode display.

0 comments

No comments yet. Be the first.
Sign in to leave a comment.