Learn how 7-segment displays really work by driving one raw — one button counts up, the other resets to zero.
What you’ll build
Each of the display’s seven LED segments hangs on its own Arduino pin through a resistor. A lookup table maps digits 0–9 to segment patterns, and two push buttons (with software debouncing) increment and reset the count — no driver chip, no library, just fundamentals.
Components you’ll need
| Component | Qty | Price |
|---|---|---|
| Arduino Nano ATmega328P Compatible Board | 1 | ₹149 |
| 7 Segment Display | 1 | ₹299 |
| Push Button 6×6 | 2 | ₹498 |
| 220 Ohm 1/4W | 7 | ₹343 |
| 400 Point Breadboard | 1 | ₹299 |
| Jumper Wires MM | 1 | ₹299 |
| Total | ₹1,887 |
Step-by-step guide
- Identify your display’s type: common cathode means the common pins go to GND (this sketch assumes that).
- Wire segments a–g to pins D2–D8, each through a 220Ω resistor.
- Connect one push button between D10 and GND (count) and another between D11 and GND (reset) — internal pull-ups handle the rest.
- Upload the sketch: the display shows 0.
- Click the count button and watch it step 0→9 and wrap around; the second button resets.
The code
The segment table is the heart of it — each row is which segments light for one digit.
const byte segPin[7] = {2,3,4,5,6,7,8}; // a b c d e f g
const byte digits[10][7] = {
{1,1,1,1,1,1,0},{0,1,1,0,0,0,0},{1,1,0,1,1,0,1},{1,1,1,1,0,0,1},{0,1,1,0,0,1,1},
{1,0,1,1,0,1,1},{1,0,1,1,1,1,1},{1,1,1,0,0,0,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1}};
const int btnUp=10, btnRst=11;
int n=0;
void show(int d){ for(int i=0;i<7;i++) digitalWrite(segPin[i], digits[d][i]); }
void setup(){
for(int i=0;i<7;i++) pinMode(segPin[i],OUTPUT);
pinMode(btnUp,INPUT_PULLUP); pinMode(btnRst,INPUT_PULLUP);
show(0);
}
void loop(){
if(digitalRead(btnUp)==LOW){ n=(n+1)%10; show(n); delay(250); }
if(digitalRead(btnRst)==LOW){ n=0; show(0); delay(250); }
}Build this project
Add all 6 required components to your cart in one click — total ₹1,887.
Add all components to cart