Self-Scoring Miniature Air Hockey Table

by DaBroom in Living > Toys & Games

321 Views, 0 Favorites, 0 Comments

Self-Scoring Miniature Air Hockey Table

IMG_8941.JPG
IMG_8942.JPG
sketch3.jpeg
sketch2.jpeg
sketch1.jpeg

This was a group project done by 6 students at Benicia High School. Caleb Friessen and Roman Hamed worked on the electronics. Arman Bance worked on the coding portions. Colin Wildermuth worked on the scoreboard. Finally, David Broom and Justin Magbitang worked on the goals.

In order for the hockey table to be working and functioning well, new goal designs were needed. A previous problem with the table is the puck would bounce out of the goal of the back and back onto the field. To improve upon the initial design we made the needed adjustments to make sure the goals were functioning properly. Along with making the goal deeper and overall bigger, we also had to account for the photoresistors and LEDs inside in order to make scorekeeping work. The new goal designs also accounted for all the wiring so the wires could stay concealed and hidden to make the hockey table have a cleaner look. Here are the initial concept and sketch designs for our goals.

Supplies

Table Supplies:

1/4" Plywood - dimensions; 80cm by 50cm

1" by 4" Pine Wood Plank - 8 ft long

M3 Threaded Insert x 8 - (optional)

M3 Bolt x 8 - 2.5cm long

Wood Screw x 12 - 6cm long

Wood Screw x 30 - 2.5cm long

Acrylic


Goal/Scoreboard Supplies:

Hot Glue Gun

Laser Cutter

Multiple ⅛” x 12” x 24” wood sheet (https://woodpeckerscrafts.com/baltic-birch-plywood-1-8-x-12-x-24/?gclid=CjwKCAjw9pGjBhB-EiwAa5jl3LUnwbdHkPBZowhWjyUGdlLEZ1MywFqVIa20QM0V3T44nnUK0-V9_RoCGfoQAvD_BwE)

A drill 

4, ½ inch screws

2 small plastic hinges (https://www.amazon.com/Acrylic-Hinge-Clear-Hinges-Self-Adhesive/dp/B09MVN13X3?th=1)


Electronics Supplies:

Raspberry Pi Pico (https://www.adafruit.com/product/4864)

Pin Header Set for Pico (https://www.amazon.com/Vilros-Pin-Header-Raspberry-Pico/dp/B08ZDP7W3D)

Breadboard / Raspberry Pi Breakout Terminal (https://www.amazon.com/BB400-Solderless-Plug-BreadBoard-tie-points/dp/B0040Z1ERO / https://www.amazon.com/whiteeeen-Breakout-Terminal-Raspberry-Board/dp/B094NLY2SN?th=1)

-You will first use a breadboard to connect to the pins on the pico but the breakout terminal will be used for the final installation in the box

Long Micro-USB cable to power Pico (https://www.amazon.com/Android-Charger-Braided-Durable-Charging/dp/B08HN6YTRN/ref=sr_1_6?crid=2D9HLDH32L1LU&keywords=long%2Bmicro%2Busb%2Bcable&qid=1682958195&sprefix=long%2Bmicro%2Busb%2Bcable%2Caps%2C133&sr=8-6&th=1)

2 LEDs (https://www.amazon.com/Novelty-Place-Transparent-Electronics-Components/dp/B01AKPKC84/ref=sr_1_2?keywords=Super%2BBright%2BLED&qid=1683733762&sr=8-2&th=1)

2 Photoresistors (https://www.amazon.com/BOJACK-Photoresistance-Sensitive-Resistor-GM5539/dp/B07TQMJ212/ref=sr_1_4?keywords=Photoresistor&qid=1683733712&sr=8-4)

2 10K Ω resistors (https://www.amazon.com/EDGELEC-Resistor-Tolerance-Multiple-Resistance/dp/B07QJB31M7/ref=sr_1_3?keywords=10k%2Bohm%2Bresistor&qid=1683733591&sr=8-3&th=1)

2 330Ω resistors (https://www.amazon.com/BOJACK-Single-Resistor-Resistors-200pcs/dp/B07R321RJH/ref=sr_1_10?keywords=330+ohm+resistor&qid=1683733632&sr=8-10)

30 Male to Male Jumpers (you won’t need this many but extras are helpful) (https://www.amazon.com/Solderless-Multicolored-Electronic-Breadboard-Protoboard/dp/B09FP517VM/ref=sr_1_4?keywords=jumper%2Bwires%2Bmale%2Bto%2Bmale&qid=1683733678&sr=8-4&th=1)

3 USB Type A Male Terminals (https://flashtree.com/products/10pcs-usb-a-type-male-socket-adapter-board-with-3-81mm-spacing-terminal-adapter-connector-dip-for-diy-usb-power-circuit-board-design?_pos=4&_sid=1547436e5&_ss=r)

3 USB Type A Female Terminals (https://flashtree.com/products/00018?_pos=1&_sid=8f0858264&_ss=r)

3 USB Extension Cables

5V 40W AC Adapter Power Supply (https://www.amazon.com/ALITOVE-Converter-Transformer-5-5x2-1mm-100V-240V/dp/B078RZBL8X)

Barrel Jack Terminal Block (https://www.pololu.com/product/2449)

10 Male to Female Jumpers (https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/ref=sr_1_3?crid=2J3ULDXX456JI&keywords=male+to+female+jumpers&qid=1685116761&s=electronics&sprefix=male+to+female+jumpers%2Celectronics%2C137&sr=1-3)


Contruct the Table

Roman: 

https://www.instructables.com/DIY-Low-Cost-Air-Hockey-Table/


Our Air hockey table is a modified version of the one I linked above in the instructable, there isn't much similarity except the materials of the base and the dimensions. When you are building the frame, don't follow the electronic guides, or anything that is not made up of wood. We only need the base frame that is made of wood because we made sufficient upgrades to improve the experience on the other aspects such as the goals and the scoreboard. Also, in the guide it has the material of the top part with holes of the air hockey made up of wood, but we found that regular plywood works perfectly as a replacement. 



Constructing the Goals

SemiFinished.jpg

Here is the file to laser cut the goals: https://drive.google.com/file/d/1d5H81uy7eCVIUsJNSdMd4D9f5ZZWMKz4/view?usp=sharing

There are many pieces to glue together and so the easiest way to do this properly will be to follow my step by step guide with pictures.

Furthermore, you should only assemble part of the goal, then install the lighting and scoring electronic system, then completely assemble the goal after. This will be in the steps but be aware of this.

Glue together with hot glue.

Steps 3-12 will show the process for gluing with pictures for the easiest way to put the goals together:

First Pieces

1111.jpg
111.jpg
11.jpg
1.jpg

Add the two pieces which fit between the two L-shaped pieces. These pieces should be flush and be on the inside of the L’s. Furthermore, the hot glue should be placed along the outside as pictured so it does not interfere with the scoring process.

Back Piece

2222.jpg
222.jpg
22.jpg
2.jpg

Next, you should add the back piece. This is where you will reach your hand to take the puck out. This should be made flush with the upper part picture rather than the bottom because another piece will be added here later. Again, hot glue should be applied on the outside.

Top Piece

3.jpeg

Next, add the top piece. This should line up with the back piece that was just put on. Hot glue can go on the inside or outside here.

Stopper

44.jpg
4.jpg

Add the stopper. This will make sure the puck does not bounce back if hit very hard. Feel free to go crazy with the hot glue wherever you want  and just make sure that the piece is roughly at a 45 degree angle.

Electronics

5.jpeg

You should stop here and go to step 19 in the electronics section to install the electronics. After installing the electronics, you can resume this section. When you are done it should look something like this.

Bottom Piece

66.jpg
6.jpg
669.jpeg

Next you should put the bottom piece on. This piece should look the same as the top piece. Make sure to glue this on the inside rather than the outside. This is because you may be putting the goal flat on a table and glue would make it so it wouldn’t be flat.

Front Piece

7.jpg

Put on the front piece. Here make sure not to glue on the front part of the front piece or else it will not be flush with the table.

Attatching the Goal to the Table.

88.jpg
8.jpg

Drill the goal into the table. This can be done by drilling from the inside of the goal. You will be going through the posts on the front piece and into the hockey table. The goal should be able to hang without being on some other support. Use a ½ inch screw.

Side Pieces

999.jpg
99.jpg
9.jpg

Add side pieces. The side piece closest to the scoreboard should be attached with a small hinge so that the electronics are accessible in case of failure in the future. Furthermore, using a drill, create a small hole near the bottom corner as pictured so the cord may be able to fit through the wood.

Repeat for the Second Goal

Repeat steps 3-11 in order to create the goal that belongs on the other side of the hockey table.

Constructing the Scoreboard

SB1.jpg
SB2.jpg

Another part of the hockey table we changed was the scoreboard. The Air Hockey Table’s scoreboard is essentially just a box. It consists of a few holes for 2 USB cables which connect the goals to the box, as well as another hole for the power cable. It also consists of a pre-cut hole for our scoreboard screen to sit in. I made the box through MakerCase (https://en.makercase.com/#/) so that it would go together and come apart easily. (this will pre make tabs so the box can be assembled easily) The box is 12 inches tall, 5.5 inches wide, and 2 inches deep. The holes for the cables are about 0.25 inches wide and 0.5 inches tall. This makes for a pretty nice fit. The scoreboard’s hole for the screen is 1.625 inches tall and 4.75 inches wide. This gives it a nice tight and flush fit. The laser files for this box can be found HERE


Electronics

b.jpg
a.png

Here is a created a circuit diagram on fritzing.org for the wiring of the pieces that will be inside the goal. Some pictures will also be shown of the real components and explain the steps taken to create them. What the wiring will look like physically at the end is also pictured.


Create the First Circuit

c.jpg

Before doing these steps remember to not make the connections too close because then you won’t be able to put the LED and Photoresistor on opposite sides of the goal.

  1. Solder a 10K ohm resistor to one of the leads on the photoresistor (LDR).
  2. Then solder a 330 ohm resistor to the positive lead of the LED.
  3. Then, connect the 10K resistor to the negative lead of the LED by soldering a jumper cable between those two connections, so that the LDR and the LED have a shared GND wire.
  4. Put that GND wire in the GND pin of the male USB breakout terminal.
  5. Connect a second wire to the same side of the LDR that has the 10k resistor and connect this to the D- pin of the same male USB terminal. This is the wire that will read the value of the LDR and will do the scoring.
  6. Connect the 330 ohm resistor (from the positive side of the LED) to the end of the LDR that is not connected to anything yet. Use a jumper wire in between this connection too. This will be the shared 5V (+) wire that connects to the 5V pin of the breakout terminal.
  7. Connect the shared 5V (+) wire to the 5V pin of the breakout terminal.


Create the Second Circuit

For the second circuit, you make the same circuit as the first with another male breakout terminal. Part 5 (Connecting a second wire to the same side of the LDR) is also a little different; you have to connect the jumper wire to the D+ pin of the second male breakout terminal so that they are on separate pins of the Pi Pico.

Connect Both of the Circuits to One USB Terminal

d.jpg

For this step you will have to connect a female USB terminal to each of the first two circuits. Then get your 3rd male USB terminal and connect the VBUS (+) jumpers to the 5V (+) pin and the GND (-) jumpers to the GND (-) pin. There will be two jumpers in the 5V (+) pin and two jumpers in the GND (-) pin. When you connect the D- and D+ pins make sure that they are in the correct spots or else the code won’t run properly. There will only be one jumper in each of the D- and D+ pins.


Connect the One USB Terminal to the Pi Pico

e.jpg
  1. Connect the GND wire to the pin that is labeled “GND” - this is 3 pins down
  2. Connect the D+ wire to the pin that is labeled “GP27” - this is 9 pins down
  3. Connect the D- wire to the pin that is labeled “GP26” - this is 10 pins down or right under “GP27”
  4. Connect the VBUS wire to the pin that is labeled “3V3OUT” - this is 5 pins down


*If you are confused with the wiring, the Fritzing diagram at the top of this section should help a lot

Put the Circuits in the Goals

g.jpg
f.jpg

For this step you’re going to have to drill two holes on either side of the goal before you put the out sides on. Stick the LED and LDR on either side of the goals and then used a hot glue gun to keep them in place. Then tape the wires down to the inside of the goal so they’re not moving free inside.

Mount the Pi Pico in the Scorebox

h.jpg

The “D-” usb port is on the left side of the box and the “D+” usb port is on the right side of the box. So make sure the goal with the “D-” usb wiring is on the same side of the box that you put the “D-” usb port on and same with “D+” side.

Connect Extension Cables

ii.jpg
i.jpg

Now you can connect the goals to the score box with your first two extension cables.

Connect MicroUSB Cable to Pico and Glue It to Back of Score Box

jj.jpg
j.jpg

The micro USB cable connects to the top of the Pico and then we glued the other end inside the hole in the back of the box so that just the metal tip was sticking out the back.

Connect to External Outlet

k.jpg

Once you have the end glued, you can connect it to an external outlet with the third USB extension cable. This cord can be used to program the pico, but it is plugged into an outlet for reference.

Wire the Score Board and Power Cable

l.jpg

The SCL pin connects to the GP8 on the pico and the SDA pin connects to GP9 on the pico

The GND pin can connect to any ground on the pico

The +5V pin connects to the VSYS pin on the top right of the pico

The VIO pin connects to the 3V3OUT pin on the pico

Fully Powering

mm.jpg
m.jpg

For the AC power adapter you have to drill a hole in the side of the scorebox and glue the Barrel Terminal Block inside the whole. Then, screw in a male to male jumper to the both the positive and negative terminals. Connect the positive wire to the VSYS pin on the Pico and connect the negative wire to any open GND pin on the Pico. Now everything should be powered.


Coding

Note: We are still working on the code for the scoreboard however the code for the LDR does work and it does detect the value changes.

Installations

  1. Follow instructions on this website to install micropython onto your board: https://www.raspberrypi.com/documentation/microcontrollers/micropython.html
  2. Install Thonny software on your computer and use Micropython (Raspberry Pi Pico). Choose whichever one pops up when you plug in your Pi Pico, it will show up as “MicroPython (Raspberry Pi Pico) COM#.” You find this in the very bottom right of the window. 


Test the Code

Try This Simple Code To Blink Onboard LED To Make Sure It Is Connected Properly: 

from machine import Pin, Timer

led = Pin(25, Pin.OUT)

timer = Timer()


def blink(timer):

    led.toggle()


timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)

Set Up the Photoresistor

  1. Once it is working, set up photoresistor by wiring like this: 

https://peppe8o.com/how-to-use-a-photoresistor-with-raspberry-pi-pico/


Code That Detects Value Changes

Here is the code that detects value changes when a goal is scored. When the photoresistor sees the change in light that results from the puck going into the goal, this code adds a point to the variable called “score.” copy and paste this code into Thonny and run it. When you cover and uncover the photoresistor, a point will be scored and 1 point will be added to the “score” variable.


from machine import ADC, Pin

from time import sleep


photoPIN = 26


def readLight(photoGP):

    photoRes = ADC(Pin(26))

    light = photoRes.read_u16()

    light = round(light/65535*100,2)

    return light


score = 0

while True:

    #print("light: " + str(readLight(photoPIN)) +"%")

    #sleep(0.1) # set a delay between readings

    while readLight(photoPIN) < 35:

        if readLight(photoPIN) > 35:

            print("GOAL")

            score += 1

            print("Score:" + str(score))

            sleep(5)



Download Files to Pi Pico

 Once this works, now you are ready to work on the scoreboard. Start by copy and pasting these code files onto Thonny and saving them onto the pi pico: https://drive.google.com/drive/folders/1lDyIe5zG_pYRAX-5OzMxTaXDtuJByOww

Install More Files

Manually install these two files from  “adafruit_ht16k33” and “adafruit_bus_device” by following instructions on this website: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries#non-express-boards-11-13

Make sure you hold down the bootsel mode button while plugging in pi pico to get into bootsel mode, allowing you to install files onto the pi pico.

Wire Scoreboard

Wire scoreboard like this:

Green wire (GND) to number 3.

Yellow wire (SDA) to number 11, which is GP8.

Orange wire (SCL) to number 12, which is GP9.

Purple wire (V_IO) to number 37.

Blue wire (+5V) to number 40.