Introduction: Air Hockey Table Wiring and Scoreboard
In this project, some friends and I attempted to make an air hockey table with our own wiring and code. This instructable will cover the step by step process that we used.
Supplies
LED (x2)
9V Battery
Ethernet Cable
Jumper Wires
10kΩ Resistor
Vacuum
Step 1: Make a Table
Step 2: Laser Cut the Goals and Scoreboard
We designed a laser cut template for both the box for the scoreboard and the two goals. We recommend you use ¼ in plywood for the scoreboard and ⅛ in for the goals. The fusion files are included here and can be downloaded to dxf or furth modified from there. The majority of laser cutters will work since most of the pieces are not very large. The scoreboard box is held together with m3 screws and nuts, it will also have to have some holes drilled for wherever you would like to run your wires and put your reset button. The goals fit together and are hot glued on the inside seams of each joint. You can either drill and mount the goals to the table, or you can use hot glue or another adhesive.
Step 3: Wire Up the LDR System
The LDR system is used to track when the puck crossed the goals. Each goal uses an LED, a photoresistor, a 330 ohm resistor, and a 10k ohm resistor. The LED is connected to the Uno’s digital output, and the photoresistor is connected to the Arduino’s analog input. The LED emits a beam of light within the enclosed goal housing, and the photoresistor registers this light. Once the puck passes through the goal, the beam of light is interrupted and the photoresistor registers this disruption. Each disruption signifies a point that is added to a player’s score.
LDR System Goal #1:
Arduino 5V -> 330 Ohm Resistor -> LED - LED + -> Arduino Digital Pin 9 Arduino GND -> Photoresistor -> 10k Ohm Resistor -> Arduino 5V Photoresistor -> Arduino A0
LDR System Goal #2: Arduino 5V -> 330 Ohm Resistor -> LED - LED + -> Arduino Digital Pin 10 Arduino GND -> Photoresistor -> 10k Ohm Resistor -> Arduino 5V Photoresistor -> Arduino A1
Reset to Arduino: Positive -> Reset GND -> GND
Step 4: Wire Up the 7 Segment Display
While the LDR system counts the points, the 7 Segment Display shows the points. The display is wired directly to the Arduino, without any extra components. SDA and SCL on the display go to SDA and SCL on the Uno respectively, 5V to 5V, GND to GND, and the V_10 on the display to 3V on the Uno. Every point added to the score is shown on the 7 Segment Display. The display is wired up to the arduino in the display housing, which is independent of the two goal housings and the table.
Step 5: Prepare the Ethernet Wires
Since the Uno is in the display housing, and the LDR systems are in two separate goal housings, we need a way to connect the goal systems to the display system. This can be done by using ethernet cables and the ethernet cable connector cases. We spliced the ethernet cables and connected them to the LEDs and the photoresistors. The ethernet cables were then run from the goal housings to the display housing where the Uno and the rest of the LDR system resided.
Step 6: Assemble + Put Into Housing
Once everything was laser cut, the electronics could be put into their housings. The display gets screwed into the display housing, the Uno and LDR systems are placed in the display housing box, and 2 holes are drilled in the box. One of the holes is used for a reset button, and the other to run the ethernet cables through the box. The LED and photoresistors and hot glued to the goals and finally a vacuum is plugged into the table to provide air.
Step 7: Code
For this project, we had to use several different devices that were connected to the arduino. One of these was the seven segment display, which needed its own libraries (Adafruit_GFX.h and Adafruit_LEDBackpack.h) which you can download from the arduino library manager. The other devices were two photoresistors that were used to detect scoring. The code will be attached below. The code checks if the "calibrated light level" is less than 10, and then adds 1 to the score. This code is duplicated in order to control both goals. The score is then written on the display, and a delay is applied to prevent a goal from being counted twice. The code is below.