Read The Times Australia

Daily Bulletin

How we built an Arduino-powered ping pong scoreboard

  • Written by: Mark Cipolla, Senior Developer & Content Platform Project Coordinator, The Conversation

At The Conversation, we take table tennis very seriously. After setting up a new ping pong table, and wanting to learn how to use an Arduino, I had a bit of time to build a scoreboard.

An Arduino is a small, programmable device that can take inputs (in this case, two buttons) and control outputs (a LED screen to show the score).

The Arduino, and the components we used

The Arduino board is a relatively cheap one; at A$29, it’s a steal. It’s a great starting board, and easy to get your head around.

The LED matrix is a 32x16 display (512 LEDs in total). It provides a set of pins at the back to wire it up to the Arduino. The wiring documentation is a bit tricky to find, so I’ll save you the trouble.

Nick Browne and I spent quite a while figuring out what buttons would be appropriate. Many were too small, or had a toggle state. Eventually, we settled on some that had the right feel; we were after a tactile, satisfying click.

Additionally, we also bought a number of small components. These aren’t quite the ones we bought, but the links show equitable parts.

Prototyping the idea

When we started prototyping, we used some push buttons to act as inputs to the digital pins on the Arduino.

During the ping pong game, each player pushes a button at their end of the table to increment their score after winning a point.

In the prototype, the buttons were a break in the circuit. Pushing the button connected the circuit, which we detected as the input.

image Arduino, with two small breadboards to prototype the buttons. Author provided

The buttons are wired into a digital input pin and an analog ground pin. I’ve used pins 2 and 3, as you will be able to see in the code later on.

Wiring up the LED matrix to the Arduino was a challenge. The cable provided didn’t work for us, and we think might have been faulty. We ended up using a bunch of individual wires.

image Arduino wired to the LED matrix. Author provided

Writing some C

Arduino is programmed in C, and runs a set of C/C++ functions. I’ve not written in a static-typed language before this project, nor a compiled one either, so this was new to me.

The Arduino looks for two specific functions, setup() and loop(). setup(), unsurprisingly, is run once and sets up the things you need for when the program is running.

Before you declare setup(), you can write a number of structs and constants.

All the data on a player, for example, can be written as a struct. Here’s a cut down version of it:

typedef struct Player {
  int pin;
  int buttonInputState;
  int buttonState;
  int score;
} Player;

We also set the constants that measure what state the game is in.

The setup() is where we’ve set up all the default values: it sets player1pin and player2pin to inputs, and tells your Arduino to listen on certain pins. digitalWrite lets you listen for certain voltages, and so, listen for button presses.

Then, we’re setting up the default values for the two player structs.

Here’s a cut down example of the setup() method in the code.

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(player1pin, INPUT);
  pinMode(player2pin, INPUT);
  digitalWrite(player1pin, HIGH);
  digitalWrite(player2pin, HIGH);

  for (int i = 0; i < NUMBER_OF_PLAYERS; i++) {
    players[i].buttonInputState = LOW;
    players[i].buttonState = UNPRESSED;
    players[i].score = 0;

    // the last time the output pin was toggled
    players[i].lastDebounceTime = 0;
  }
}

We use constants to set the states, and the loop() progresses to the correct state once each small method is completed.

const int GAME_WAITING = 0;
const int GAME_START = 1;
const int GAME_ON = 2;
const int GAME_OVER = 3;

The loop() is what runs continuously, and we’re using a variable named game_state to know which stage of the game we’re at. It then runs smaller methods that control each stage.

void loop() {
  switch(game_state) {
    case GAME_WAITING :
      game_state = wait_for_players();
      break;
    case GAME_START :
      game_state = tell_players_its_on_like_donkey_kong();
      break;
    case GAME_ON :
      game_state = game_on();
      break;
    case GAME_OVER :
      game_state = game_over();
      break;
  }
}

The GAME_WAITING state scrolls text across the screen telling the players that pressing both buttons will start. It listens for the two simultaneous button presses, and if both pressed, sets the state to GAME_START.

The GAME_START state flashes START on the screen for five seconds, giving the players a chance to get ready! Once this timer is done, it sets the state to GAME_ON.

The GAME_ON state does the majority of the work in the program. It listens for buttons pushes and then increments the count. Then, it draws the scores on the LED matrix.

It keeps track of the scores, checking if either score is above 21, and if a player’s score is more than two points greater than the other. If these conditions are met, it sets the state to GAME_OVER.

The GAME_OVER state figures out who won, and shows either P1 WINS or P2 WINS. Then, after waiting for a few seconds, it resets the state to GAME_WAITING.

I’ve made the source code for the Arduino available in a GitHub repository. Please take a look!

Wiring everything up

We simplified how buttons worked as inputs. We were able to remove the resistors and use the internal ones available on the Arduino’s digital inputs.

pinMode(pin, INPUT);     // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors

The buttons keep the circuit connected, and pushing the button broke the circuit, which we used to detect the input.

image Wiring schematic of the buttons connected to the Arduino. Author provided

We soldered everything together, adding a small prototype circuit board to organise the wiring from the Arduino to the two 3.5mm headphone jack pins.

image The circuit board, with wires running from the Arduino to the two 3.5mm headphone jacks. Author provided

From the headphone jacks, we ran two 3.5mm male to male cables. These connected to two other 3.5mm headphone jacks, fixed into plastic enclosures that also held the buttons.

image The enclosures, with buttons on one side, and a headphone jack on the other, before they’re wired up. Author provided

I’m a bit of an amateur woodworker, so I made up a pine frame to fit the LED matrix panel. Four sides, each with 45 degree cuts, and some small brackets to fit them together.

A little sanding and varnishing, and it looks pretty good.

The finished product

With the LED matrix fitted into the timber enclosure, we’re ready to turn it on and do some testing!

image Enclosure with the LED matrix fitted. Author provided

As you can see in the movie below, both players have to press their buttons simultaneously to start the game. Once it’s started, each player pushes their buttons to increment their score after winning a point.

Once a player has more than 21 points, and has two more than their opponent, we have a winner!

Button pressing in action!

Authors: Mark Cipolla, Senior Developer &amp; Content Platform Project Coordinator, The Conversation

Read more http://theconversation.com/how-we-built-an-arduino-powered-ping-pong-scoreboard-69401

Business News

Designing Eco-Friendly Custom Water Bottles for Your Next Event

The Evolution of Sustainable Event Merchandise Event planning has undergone a massive transformation over the last decade. Gone are the days when organizers could hand out cheap, single use plastic...

Daily Bulletin - avatar Daily Bulletin

Why Choosing a Professional Florist Melbourne Makes Flower Delivery Impactful

Flowers have a great power to speak when humans cannot express their feelings with right words. Flowers are the best gifts when you are celebrating a birthday or welcoming a newborn child into your fa...

Daily Bulletin - avatar Daily Bulletin

The Business Case for Choosing Australian Fabricators Over Imported Alternatives

For a long time, you might have defaulted to overseas suppliers when sourcing fabricated metal components for a project. The unit price was lower on paper, and the maths seemed straightforward. That...

Daily Bulletin - avatar Daily Bulletin

Australian organisations are relying on business continuity plans built for a far more predictable world

Tariff escalations, supply chain fragility, geopolitical events, and the ongoing threat of cyber disruption have reshaped the risk environment facing Australian organisations. The problem is that ma...

Daily Bulletin - avatar Daily Bulletin

How to Rent a Car for Uber in Melbourne: What Every New Driver Needs to Know

Starting out as an Uber driver in Melbourne is not as complicated as it sounds but getting the vehicle right is where most new drivers get stuck. Uber has strict requirements around vehicle age, condi...

Daily Bulletin - avatar Daily Bulletin

When Should You Speak to a Lawyer About a Legal Issue?

Legal issues can begin with a simple question, then become harder to manage once formal steps are involved. Many people wait until a matter feels urgent before seeking guidance, even though earlier ...

Daily Bulletin - avatar Daily Bulletin

The strategic rise of Bali as Australia’s next essential healthcare support hub

As Australian healthcare providers grapple with unprecedented operational bottlenecks, a new nearshore model is quietly transforming patient care delivery. Forward-thinking organisations,  including...

Daily Bulletin - avatar Daily Bulletin

Cost Savings and Benefits of Using Used Pallets in Logistics

In today’s competitive logistics and supply chain industry, businesses are constantly looking for ways to reduce operational costs without compromising efficiency and reliability. One of the most prac...

Daily Bulletin - avatar Daily Bulletin

How Fulfilment Services in Australia Help Businesses Scale Efficiently

The growth of e-commerce and modern retail has transformed customer expectations. Consumers now expect fast shipping, accurate order processing, and seamless delivery experiences regardless of where...

Daily Bulletin - avatar Daily Bulletin

The Daily Magazine

How to Get a Document Notarised in Sydney: What to Bring, What It Costs and How Long It Takes

If an overseas bank, embassy, university, employer or land registry has asked you for a notarised ...

The 2026 Used-Car Market

For a few strange years, the used-car market rewrote its own rules. Supply shortages sent second-h...

Why CCTV Alone Is Not Enough for Modern Business Security

Cameras are usually the initial step that companies take to strengthen their physical security. If...

Why Every Workplace Should Take Emergency Preparedness Seriously

Emergency planning is one of those things many workplaces know they should think about, but it oft...

Why Clearer Communication Still Matters in a Digital-First Business

It’s never been easier for businesses to communicate, but that doesn’t mean they’re always communica...

What Happens After You Lodge a BYDA Enquiry? The Step Most Excavation Projects Miss

Every excavation project in Australia — from a backyard deck footing to a multi-storey commercial bu...

How to Choose the Right Dentist on the Gold Coast

Finding a dentist you trust is one of those decisions that quietly affects your health for years, ye...

The Hidden Engineering Problem Inside Australia's Older Housing Stock

A significant share of Australian homes were built for a way of living that no longer exists. Houses...

DIY Rodent Control Vs Professional Help: When Is It Time To Call The Experts?

Rodents are one of the most frustrating pest problems for Australian property owners. Rats and mic...