Build it step by step
0 of 8 doneInstall the TM1637Display library
From the Library Manager.
Wire the bumpers
D2 to D4 and GND.
Wire the new ball button
D5 and GND.
Wire the display and the LEDs
Display on D6 and D7, LEDs on D8 to D10 through 220 ohms.
Wire the buzzer
D11 and GND.
Upload the sketch
The display shows 0.
Press the bumpers
Score rises by 10, 20 or 50 with a beep.
Press new ball three times
After ball three the game ends and the score flashes.
How do you build a pinball score counter?
Three bumper switches on a model pinball table each score a different number of points on a four-digit display, with a beep and a flash for each hit, and a button to start a new ball. A good small project in counting and display, and a way to build a game table from card. You need Arduino Nano, Tactile push button 6 mm × 4, TM1637 4-digit display, Passive buzzer, LED 5 mm red × 3, Resistor 220 Ω × 3, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 80 minutes.
- Level
- Beginner
- Time
- About 80 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Nano × 1
- SwitchesBuy
- DisplaysBuy
- Motors & ActuatorsBuyPassive buzzer × 1
- SemiconductorsBuyLED 5 mm red × 3
- PassivesBuyResistor 220 Ω × 3
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Bumper switches 1 to 3 | Nano D2, D3 and D4 and GND | Worth 10, 20 and 50 points |
| New ball button | Nano D5 and GND | Starts the next ball |
| TM1637 CLK and DIO | Nano D6 and D7 | Score display |
| TM1637 VCC and GND | Nano 5V and GND | Power |
| Bumper LEDs 1 to 3 long legs | Nano D8, D9 and D10, each through a 220 ohm resistor | Flash on a hit |
| LED short legs | Nano GND | Return |
| Passive buzzer + and - | Nano D11 and GND | Hit sounds |
Code
Each bumper is a switch that closes when the ball touches it, which you can make from two strips of foil on card or from three small push buttons. The sketch gives each bumper its own points (10, 20 and 50), adds them to the score, shows the score on the TM1637 display, beeps at a pitch that depends on the bumper and flashes that bumper's LED for a short time. A hit is ignored if it follows the last on the same bumper within 80 milliseconds, which stops one touch counting several times. The new ball button moves to the next ball, and after the third ball one more press ends the game and flashes the final score, and the next press starts a fresh game. The flash of the LEDs uses the clock instead of delay, so the score never hangs. Install "TM1637Display" by Avishay Orpaz from the Library Manager. Build the table from card at a gentle slope, use a light ball such as a marble-sized foam ball, and keep marbles away from small children. Try adding a combo bonus when two different bumpers are hit within a second.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Library: TM1637Display (by Avishay Orpaz).
#include <TM1637Display.h>
const uint8_t BUMPER[3] = {2, 3, 4};
const uint8_t BUMPER_LED[3] = {8, 9, 10};
const unsigned int POINTS[3] = {10, 20, 50};
const uint8_t BTN_NEW = 5;
const uint8_t CLK = 6;
const uint8_t DIO = 7;
const uint8_t BUZZ = 11;
const uint8_t BALLS = 3;
TM1637Display display(CLK, DIO);
unsigned int score = 0;
uint8_t ballsUsed = 0;
bool prevBumper[3];
bool prevNew = false;
bool gameOver = false;
unsigned long flashUntil[3];
unsigned long lastHit[3];
void showScore() {
display.showNumberDec(score, false);
}
void setup() {
for (uint8_t i = 0; i < 3; i++) {
pinMode(BUMPER[i], INPUT_PULLUP);
pinMode(BUMPER_LED[i], OUTPUT);
}
pinMode(BTN_NEW, INPUT_PULLUP);
pinMode(BUZZ, OUTPUT);
Serial.begin(9600);
display.setBrightness(3);
ballsUsed = 1;
showScore();
Serial.println(F("Ball 1"));
}
void loop() {
unsigned long now = millis();
for (uint8_t i = 0; i < 3; i++) {
bool down = (digitalRead(BUMPER[i]) == LOW);
if (down && !prevBumper[i] && !gameOver && now - lastHit[i] > 80) { // ignore contact bounce
lastHit[i] = now;
score += POINTS[i];
if (score > 9999) score = 9999;
showScore();
tone(BUZZ, 800 + i * 400, 60);
flashUntil[i] = now + 150;
}
prevBumper[i] = down;
digitalWrite(BUMPER_LED[i], now < flashUntil[i]);
}
bool n = (digitalRead(BTN_NEW) == LOW);
if (n && !prevNew) {
if (gameOver) { // start a whole new game
score = 0;
ballsUsed = 1;
gameOver = false;
showScore();
Serial.println(F("New game. Ball 1"));
} else if (ballsUsed < BALLS) {
ballsUsed++;
Serial.print(F("Ball "));
Serial.println(ballsUsed);
} else {
gameOver = true;
Serial.print(F("Game over. Score "));
Serial.println(score);
for (uint8_t k = 0; k < 3; k++) { // flash the final score
display.clear(); delay(200);
showScore(); delay(200);
}
}
}
prevNew = n;
delay(5);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Ball 1
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Bumper 1 | Score up 10 with a low beep |
| Bumper 3 | Score up 50 with a high beep |
| Quick repeat hit | Counted once |
| New ball button | Next ball on the serial monitor |
| After the last ball | Game over and flashing score |
If it does not work
Library not found
Install TM1637Display.
Display stays blank
Check CLK to D6 and DIO to D7.
A bumper counts twice
Increase the 80 millisecond gap.
A bumper does nothing
Check its wiring to its pin and GND.
LED stays dark
Check its direction and the 220 ohm resistor.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the pinball score counter?
Arduino Nano, Tactile push button 6 mm × 4, TM1637 4-digit display, Passive buzzer, LED 5 mm red × 3, Resistor 220 Ω × 3, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the pinball score counter take to build?
About 80 minutes for a beginner maker, in 8 steps.
How do I know the pinball score counter works?
Bumper 1: Score up 10 with a low beep. Bumper 3: Score up 50 with a high beep. Quick repeat hit: Counted once.
Library not found: what should I check?
Install TM1637Display.
Display stays blank: what should I check?
Check CLK to D6 and DIO to D7.
A bumper counts twice: what should I check?
Increase the 80 millisecond gap.
A bumper does nothing: what should I check?
Check its wiring to its pin and GND.
