Interactive Pong Table
This tutorial will cover how a friend and I designed, developed and built an interactive pong table.
We set ourselves the requirements that the table needed to fix into a fiat punto and transported. LED's should be incorporated within the table, and there should be some way to track the score.
In the final design, the main aspects are:
- Legs fold up into the body of the table for ease of transport
- A pair of Infra-red emitters and receivers are located under each cup
- The centre 14 x 20 LED matrix which is used as a display
- Buttons located per side so that the cups can be reset easily, to control the menu and mini-games ( Classic Pong, 2 player snake) can be played
Supplies
Pine
o 2 x 1806mm x 170mm x 20mm
o 2 x 550mm x 170mm x 20mm
o 2 x 528mm x 77mm x 20mm
o 2 x 508mm x 32mm x 20mm
o 4 x 438mm x 63mm x 38mm
o 4 x 730mm x 63mm x 38mm
Opal Perspex
o 1 x 1604mm x 528mm x 3mm
Birch Plywood
o 1 x 1604mm x 528mm x 3mm
o 1 x 1786mm x 526mm x 3mm
Threaded Steel bar
o 2 x 570mm x 10mm
Grid and Miscellaneous
o 4 tubes of pringles – Cut to 31mm tall
o 7 empty toilet paper tubes - cut at 31mm tall
o 3 5mm foam board – cut to various si
o Dark walnut stain
o Clear outdoor varnish
Electronics
o 8 - 24PCS Arcade Buttons Arcade DIY Push Button for Arcade Joystick Games Console 6 Colors Buttons
o 4 - AITRIP Nano V3.0, Nano Board ATmega328P 5V 16M Micro-Controller Board Compatible with Arduino IDE
o 1 - XLX 50 pairs 5mm 940nm Infrared Diode LED Emission and IR Receiver
o 1 - TUOFENG 16 AWG Silicone Electrical Wire 2 Conductor Parallel Wire 10 Meter [Black 5 m Red 5 m] Soft and Flexible Tinned Copper Wire 1.3mm² Hook Up Wi
o 1 - 20 Gauge Wire Solid Core Hookup Wire - Pre-Tinned PVC Coated Copper Wire of 6 Colors (Black, Red, Yellow, Green, Blue, White) 29ft/9m Each, Hook Up Wi
o 1 - 5v 200W 40A DC Universal Regulated Switching Power Supply for CCTV,Radio,Computer Project, 3D Printer, LED Strip Lights(IP20 5V 200W 40A)
Step 1 - Table Design
The cut list can be seen in the supplies list. We modelled the final concept in Siemens NX to ensure that all the dimensions were correct, and it gave us an insight into what the final project should look like.
Many of the materials used are cut to simple rectangular dimensions; we achieve these cuts using a jigsaw.
There are 3 main complex components, the Long Body piece, short body piece and main legs:
- Long Body Piece - This is the most complicated piece to make as it involves multiple levels of inserts in different orientations. We ended up using dovetail joins as it's a more aesthetic joint. Use a 6mm router bit and a distance guide to achieve the 6mm slots, recommend completing 3 cuts increasing the depth by 2mm each pass. Complete the top 5mm slot using an upright position and use a ball-bearing guide to ensure it is inlaid.
- Short Body Piece - This is a simple version of the long piece as there is only one 6mm slot required which runs the length of the piece; ensure that the router bit doesn't contact the dovetail joint as the weaker wood might break off.
- Main legs - These are made from 38mm pine. The 7-degree angle is associated with the 12mm hole on the long body piece; this ensures that the legs lay at the correct angle on the floor and when it is in contact with the short body piece. The rounded top is a suggestion bit ay clearance which allows the leg to pivot is acceptable.
Table Assembly
Assembly is split into 2 main sections, The main Body and then the legs. PVA was used on the dovetail joints, and a thin layer was also set in each slotted area. As seen in the picture, the way we assembled the body was to get 3 sides on, slot down both levels of plywood and then place the last long body piece over the top. Key things for assembly:
1 - Cut each corner of the plywood at a 45-degree angle around 8mm deep as, without this, all 4 body pieces will not match up properly.
2- Do a dry fit before using any glue; this ensures that all the pieces have been cut to the correct lengths and is the best practice.
3 - When glueing, if possible, use a band clamp to ensure that the body sets correctly at the right angle; if this is set wrong, the perspex will not slot incorrectly, causing future problems. We didn't have this, so we used 2 F clamps for both edges and then used a rope around the centre to stop the wood bowing. (Ensure to never clamp directly onto the target, use scrap wood between the target and clamp to preserve the target finish.
4 - The legs are easily assembled using glue and screws in the cross supports. When drilling the support clearance holes, ensure that the outer surface has been countersunk so that no screw head is pultruding out, which would hinder the legs from slotting into the body correctly.
Electronics Calculations
The current draw for each section was calculated by looking at the datasheets for components then a combined value was used to work out the power requirements. From this, a suitable power supply of 120W was selected, allowing for a total of 40A max. This was greater than the requirements to allow for headroom. The sections were calculated as follows:
LED MATRIX - (WS2812b LED strip @ 5V)
- Number of LEDs = 14 * 20 = 280
- Power per LED = 0.3W
- Total power of grid = 0.3W x (280) = 84W
- Current draw of matrix = 84W / 5V = 16.8A = ~ 17A
SENSOR LEDs - (WS2812b LED strip @ 5V)
- Number of LEDs = 30 per side (60 total for all sensor LEDs)
- Total power = 60 * 0.3W = 18W
- Current draw = 18W / 5V = 3.6A
MICROCONTROLLERS & SENSORS
- Current draw per IR emitter and receiver = 20mA
- Number of IR LEDs = 20
- Current draw of Arduino Nanos = 200mA
- Arduino Nanos = x4
- Total current draw = 20mA x 20 + 200mA x 4 = 1.2A
TOTAL
- 1.2A + 3.6A + 17A = 21.8A (40A PSU is more than enough with lots of clearance and room for upgrades)
After calculating the current draw for each component, the required wire thicknesses were calculated using the website below:
https://www.wirebarn.com/Wire-Calculator-_ep_41.ht...
- 16AWG cable was used for the main LED matrix
- 23AWG Cat6 cable was used for wiring the sensors and buttons
- 20AWG cable was used for all other connections
Maximum cable lengths should be calculated and not exceeded.
Infra-red Sensors
The sensor circuit was made on a single-sided stripboard that was cut to be around 7x8 holes big to fit the diameter of a toilet paper roll. A simple circuit was then created, as seen in the picture above. It is important to get the Transmitter and Receiver to sit just below the perspex. This is achieved using 3 small foam sheets under the board. The minimised distance will create a larger received signal when the cup is located on the table, and therefore the score change will be more accurate.
On an Arduino nano, there are only 5 data pins. To cover all 10 cup slots, we split the sensors up into 2 sections indicated in red and green on the figure above. 2 Arduino Nanos are therefore used to control the sensors per side. We fully understand that this is not the most efficient way of achieving the goal but it carried over from the concept design stage and was never revisited.
Once both audios have been fully wired and soldered correctly to the stripboard, we use flame retardant ploy on the back of the boards; this was a safety precaution to reduce fire risk if the board was overloaded.
14 X 20 Matrix
Use the making guide in the photo above to mark out the centre of the table and key dimensions.
The centre matrix is made by cutting up LED strips and then reconnecting the ground, 5 volts and data with 16dwg wire. When cutting the LED strips, make sure that the cut is through the centre of the copper pins; this is extremely important as you will need copper visible to solder the wires onto.
After all 14 strips of 20 LEDs have been cut, it's time to lay them onto the base following the figure above, where the point indicates the location of the centre of the LED. (PAY CLOSE ATTENTION TO THE ARROWS ON THE STRIPS) The arrows indicate flow direction, and the wires must be following each other; picture it as a snake, and the direction should reverse each row.
Due to the current required to run the LEDs, the grid is split into 4 sections. 2 sections are made up of 3 rows each, and the other 2 sections are 4 rows each. The top 2 sections are the 3 rows. At the input and output of each section, a hole needs to be drilled through the base so that data wries can run under the Arduino.
The foam grid is cut from 5mm black foam ( We spray painted white) and use a simple cross lap joint. 15 lengths of 690mm and 21 lengths of 487mm lengths. We made a wooden jig that could lay on top of the foam and then used a craft knife to remove the slots.
Cup LEDs
There are 3 LEDs used to create each of the 10 rings. The dimensions are shown in the figure above are important to get accurate as the cup rims only have 1-2mm separation using these dimensions. Individual LEDs sit in between the 2 rings, which are made from cutting up a Pringles tube with a 75mm diameter and toilet paper tubes with a 42mm diameter. These rings should be cut with a craft knife to a height of 35mm.
After laying down all 30 LEDs in the right orientation and at the correct location, it is time to wire them up. Seeb in the figure above, the orange arrows represent the path the data cables should take around the LEDs compared to the blue, which indicates the ground and 5v path. It is essential to get the wring correct to cut and stripping wires to the shortest sizes to minimise overlap.
Place the outer rings over the writing takes some trial and error; each ring will contact different wires in different locations. To ensure that there is limited light leakage, line up the ring and contact using the craft knife, cut a slot. Doing this around the circumference of the ring will create the desired result. Use a hot glue gun to secure the ring down, Don't place any clue near the open connection points as this will cause the circuit to be short.
We decided to separate each LED so that it would be more prominent if multiple colours we needed. Separation is achieved by simply cutting up foam and placing it in the correct location; hot glue is then placed around the joints to secure it to the ring.
Buttons
The buttons were single arcade buttons which allows control of the menu, calibration of cups and control of the mini-games. They use CAT 6 cabling (23AWG) and are connected to the ground and digital pin. Within the code set the digital pin to high, this will cause the pin to read 0 when the button is pressed.
Code Base
We used audrunio microcontrollers programmed using the Arduino IDE. These communicate using the I2C protocol with twisted cables running through the centre of the table. This allowed us to transfer button presses and sensor information to the main controller, where it could be processed for updated the score and playing mini-games. We used the fastLED neo matrix library below:
https://github.com/marcmerlin/FastLED_NeoMatrix
The library allows us to draw text and other graphics easily without having to define individual pixels. This can be used to create scrolling text and display bitmap images.
The code is split up into three main parts: sensors controller, button controller and main controller.
Sensor Controller
The sensor controller continuously read the IR receiver values using the Analogue to Digital converter on the Arduino Nanos. A software moving average filter was then applied to reduce noise on the signal, and the sensor value was converted to a binary 0 or 1 based on the calibration values for the sensors.
The calibration works by the user holding all 4 buttons for three seconds. The LEDs will then flash to indicate that they are ready for calibration. A value is taken from each of the IR circuits for a cup on and a cup off. These values are used to determine when a cup is detected or not to give the binary 0/1 value.
Button Controller
The button controller is similar to the sensor controller in that it constantly polls the button digital pins. The buttons are wired up to GND and a digital pin that is floating high. When the button is pressed, the digital read function returns a 0, and a 1 when the button is not pressed. These values are appended to an array ready to be requested by the main controller over I2C.
Main Controller
The main controller requests sensor and button values from the two slaves over I2C. It then uses these values for different modes. Currently, the main controller will launch the main menu where the user can select between "Beer pong", "Danger Pong", "Snake", and "Classic Pong". These are selected using button presses. By pressing all 4 buttons concurrently, the menu will select the mode or re-open.
The code can be found on GitHub using the link below: