ArrowtronElectronics Store
Free shipping over ₹999
100% genuine components
Dispatch in 1–2 days
Secure payments · UPI, Cards

7-Segment Push-Button Counter (No Libraries Needed)

Learn how 7-segment displays really work by driving one raw — one button counts up, the other resets to zero.

Beginner~1 hour6 components

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

ComponentQtyPrice
Arduino Nano ATmega328P Compatible Board1₹149
7 Segment Display1₹299
Push Button 6×62₹498
220 Ohm 1/4W7₹343
400 Point Breadboard1₹299
Jumper Wires MM1₹299
Total₹1,887

Step-by-step guide

  1. Identify your display’s type: common cathode means the common pins go to GND (this sketch assumes that).
  2. Wire segments a–g to pins D2–D8, each through a 220Ω resistor.
  3. Connect one push button between D10 and GND (count) and another between D11 and GND (reset) — internal pull-ups handle the rest.
  4. Upload the sketch: the display shows 0.
  5. 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
Scroll to Top