App | Si Digital News
Hacking our Ping Pong Table
Read about how our competitive play got out of hand
We’ve had our new Ping Pong table a couple of months now and we are in love. Our gameplay has rapidly improved since day 1, but one thing never kept up; our ability to keep score. Developers don’t have the greatest hand-eye coordination at the best of times, but combine that with competitive play and conversations, it wasn’t long before basic Math escaped us.
Why we did it
We’ll admit, having a ping pong table in this industry is a clichéd concept. A web agency deciding they need to create their own digital leaderboard to track games, even more so. There have been some great examples already of this such as Campaign Monitor’s. These are fantastic, but they all suffer from the same problem, you still need to keep score and manually save to the system at the end of each game.
In true Si digital fashion we decided to take this to the next level and automate everything…
Using tiny RFID tags we drilled into our bats, the system allows players to simply walk up to the table, have their faces immediately appear on-screen and a new game be initialised.
After scoring a point we simply tap our finger under the table and the screen automatically updates the live score.
There are audio cues to let players know when they register a point and when it’s time to switch servers. The sounds also help prevent cheating, so no ninja double tapping when your opponent turns his back!
Once one player reaches the final score of 21 with 2 points clear, the system automatically ends the game, congratulates the winner, calculates their new ranking then switches the interface back to the leaderboard. We play to 21 instead of 11 because at our current skill level the games would finish far too quickly!
There are 3 key elements to this project that let hardware and software work in unison to create ping pong utopia:
1. Keeping score
For the effortless scoring we used a capacitive touch sensor at each end of the table that the player can lightly tap to register a point. These are connected to a tiny Spark Core microcontroller that is connected to our Wifi and sends out events to the Spark cloud when points are registered.
This part of the system is attached to the underside of the table and powered by a 2500mAh battery that lasts us about a week before charging. We used a tiny un-interruptable power supply that allows us to charge the battery and play at the same time so a dead battery doesn’t stop the fun! We also ping an alert to the scoreboard in real time when the battery is low so there are no surprises mid game!
2. Automatically recognising players
Each player has their own unique bat. We’ve drilled tiny holes into the bottom of them and dropped in some seriously small 12mm RFID glass tags.
Next to the table we have an RFID reader we built using an Ardiuno Pro Mini for the brain, a CC3000 for connecting to our Wifi and a small ID-12LA RFID reader. We fit this all into a small box and covered it with a handful of LEDs to give visual feedback when you scan. The code for these are linked at the bottom of this article.
3. Live scoreboard
Node.js and Socket.io are used to ensure the score updates on screen in real time while we are playing. When certain events are triggered an appropriate sound is played.
Initially we found audio notifications a tough nut to crack. Mobile Safari is restricted to playing sounds prompted by user input, meaning that the user would have to trigger some kind of input (by tapping the screen, for example) on app launch to enable each of the sounds. After a somewhat dubious attempt to circumvent this (hot swapping an audio source), we settled on implementing an audio sprite, resulting in greatly improved performance and stability. With the help of npm build scripts and the audiosprite module, we ended up with a fast build process that outputs audio sprite data that can be handled by howler.js – the library we are using for audio playback.
We’ve open sourced everything from the server to the hardware on our GitHub repo.
UPDATE NOV 2016 – Our first table tennis hack definitely made playing a much more enjoyable experience, but after a while we knew we could improve on what we had built. Find out how we created the web app tivit, that now allows anyone to start a game, record their scores and create custom leaderboards in our blog post.