Microprocessor Core: The 8-Bit Counter
Before seven-segment displays or LCD screens, computers communicated purely in Binary code. The 8-Bit Binary Counter project uses 8 simple LEDs in a row to visually demonstrate exactly how an 8-bit ATmega328P chip (Arduino Uno) thinks and computes its numbers natively.

Register Manipulation
A beginner will write 8 lines of digitalWrite() to turn the LEDs on and off.
- The professional uses Direct Port Manipulation.
- Instead of treating every pin individually, you treat the entire group of pins as a single 8-bit "Port", for example, PORTD (pins 0 to 7).
- You create an integer variable:
int counter = 0;. - Inside the loop, you write:
PORTD = counter;andcounter++;. - The Arduino instantly converts the number into its binary representation (e.g., if counter is 5, it becomes
0b00000101and turns on LEDs 1 and 3 simultaneously).
Exceeding 255 (The Overflow)
An 8-bit register only has 8 slots.
- The highest number it can hold is
11111111in binary, which equals the number255in decimal. - When the
countervariable hits 255, and theloop()runscounter++one more time, it has run out of physical memory space. - The register Overflows back to
00000000(turning all 8 LEDs off instantly) and starts counting from zero again. This is a critical concept in memory management.
Component Sourcing
- Arduino Uno/Nano.
- 8 LEDs (Any Color) and 8 Resistors (220-Ohm).
- A Breadboard and extensive jumper wiring.
- (Optional Upgrade): A 74HC595 Shift Register to run all 8 LEDs using only 3 data pins instead of eating 8 pins on the board!