Projects / Table air hockey scoreboard

Table air hockey scoreboard

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO

    Test the IR modules

    The on-board LED lights when something is close. Pass the puck in front to see it trigger.

  2. NANO

    Fit the sensors

    Mount one inside each goal slot, pointing across the opening, below the table surface.

  3. NANO

    Wire the display

    DIN, CS and CLK to D12, D10 and D11, power from 5V and GND.

  4. NANO

    Wire the interrupts

    Left sensor to D2 and right to D3.

  5. NANO

    Upload and play

    Each goal adds a point to the other player, and the horn sounds when someone reaches 7.

  6. NANO

    Tune

    Adjust the IR trimmers until a fast puck always counts once.

In short

How do you build a table air hockey scoreboard?

IR sensors in each goal count scores and a display shows the match, with a horn at 7 points. You need Arduino Nano, IR obstacle avoidance sensor module × 2, 8-digit 7-segment module (MAX7219), Active buzzer 5 V, Jumper wires male to male (40 pcs, 20 cm) and USB A to micro-USB cable (data). It takes 6 steps and about 90 minutes.

Level
Beginner
Time
About 90 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Left goal IR module OUTNano D2Interrupt input, low when the puck passes
Right goal IR module OUTNano D3Interrupt input
Both IR modules VCC and GNDNano 5V and GNDSupply
8-digit display DIN, CS, CLKNano D12, D10, D11Display
8-digit display VCC and GNDNano 5V and GNDSupply
Buzzer + and -Nano D8 and GNDHorn

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "LedControl" by Eberhard Fahle. The IR modules are reflective, so they see the puck as it passes in front of them. Aim each across the goal slot and use the module's trimmer so a puck triggers it but the table edge does not. Digit 7 is the leftmost on most 8-digit modules.

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).

#include <LedControl.h>

LedControl lc(12, 11, 10, 1);               // DIN, CLK, CS
const byte LEFT = 2, RIGHT = 3, BUZZ = 8;
volatile bool leftHit = false, rightHit = false;
byte scoreL = 0, scoreR = 0;
unsigned long lockUntil = 0;

void onLeft()  { leftHit = true; }
void onRight() { rightHit = true; }

void show() {
  lc.setDigit(0, 7, scoreL / 10, false); lc.setDigit(0, 6, scoreL % 10, false);
  lc.setChar(0, 4, '-', false); lc.setChar(0, 3, '-', false);
  lc.setDigit(0, 1, scoreR / 10, false); lc.setDigit(0, 0, scoreR % 10, false);
}

void setup() {
  lc.shutdown(0, false); lc.setIntensity(0, 8); lc.clearDisplay(0);
  pinMode(LEFT, INPUT); pinMode(RIGHT, INPUT);
  attachInterrupt(digitalPinToInterrupt(LEFT), onLeft, FALLING);
  attachInterrupt(digitalPinToInterrupt(RIGHT), onRight, FALLING);
  show();
}

void loop() {
  if (millis() > lockUntil && (leftHit || rightHit)) {
    if (leftHit) scoreR++; else scoreL++;            // a puck in the left goal scores for the right player
    leftHit = rightHit = false;
    lockUntil = millis() + 1000;                     // ignore repeats for one second
    tone(BUZZ, 1500, 150);
    show();
    if (scoreL >= 7 || scoreR >= 7) {                // match over
      tone(BUZZ, 700, 2000);
      delay(5000);
      scoreL = scoreR = 0; show();
    }
  } else if (millis() <= lockUntil) {
    leftHit = rightHit = false;
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Puck through the left goalRight score goes up by one
Rolling the puck back and forthCounts once per second at most
Reach 7 pointsLong horn, then scores reset
Fast shotStill counted

If it does not work

Counts twice

The puck lingers. Raise the lockout time or reduce sensor range.

Misses fast pucks

Increase the module's sensitivity and make sure it sees a light surface on the puck.

Table edge triggers

Turn the trimmer down.

Display shows odd digits

Digit order differs. Swap the digit numbers in show().

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the table air hockey scoreboard?

Arduino Nano, IR obstacle avoidance sensor module × 2, 8-digit 7-segment module (MAX7219), Active buzzer 5 V, Jumper wires male to male (40 pcs, 20 cm) and USB A to micro-USB cable (data).

How long does the table air hockey scoreboard take to build?

About 90 minutes for a beginner maker, in 6 steps.

How do I know the table air hockey scoreboard works?

Puck through the left goal: Right score goes up by one. Rolling the puck back and forth: Counts once per second at most. Reach 7 points: Long horn, then scores reset.

Counts twice: what should I check?

The puck lingers. Raise the lockout time or reduce sensor range.

Misses fast pucks: what should I check?

Increase the module's sensitivity and make sure it sees a light surface on the puck.

Table edge triggers: what should I check?

Turn the trimmer down.

Display shows odd digits: what should I check?

Digit order differs. Swap the digit numbers in show().