Smart Pinball

by Pblomme in Circuits > Raspberry Pi

326 Views, 0 Favorites, 0 Comments

Smart Pinball

neon pinball.png

Ever since i was a kid, I've always liked playing with pinball machines. We had a little one when I was younger and I spent hours playing with that thing. So when my teachers gave us this assignment to make an 'enchanted object' and they give a tip to make something fun, I instantly thought of a pinball machine.


So, in this insctructable I'll walk you through this journey I took to make my version of an awesome pinball machine!

Supplies

Components:


1) Raspberry Pi (€ 39,99) x1

2) Raspberry T-cobbler (€ 3,95) x1

3) usb-c power supply 3,3V (€ 9,99) x1

4) Wood plate (€ 9,45) x1

5) LDR (€ 3,93) x1

6) Force sensitive resistor (€ 7,95) x1

7) Infrared sensor (€ 2,09) x1

8) Wooden sticks (€ 6,87) x1

9) Box of colored rubber bands (€ 2,39) x1

10) LCD-screen (€ 8,86) x1

11) Black marble (€ 0,20) x1

12) Neon stickers (€ 9,99) x1

13) Cables (€ 6,99) x1

14) Servo Motor (€ 2,10) x1


Tools:

1) Glue gun

2) Jigsaw

3) A drill

4) Wood glue

Connecting Everything

In the pdf's below you can find what and how you can connect all the sensors, the servo motor and the lcd-screen. Some of the components are set on the breadboard on the pdf, but you should connect everything with cables. That's needed to later place everything in the box.

Setting Up the Database

Screenshot 2022-06-14 144742.png

For this project, you need a database to store all the data you'll receive from the game. For this I made a database in MySQL workbench.

Make sure you have MariaDB installed on your raspberry-pi and connect MySQL workbench to your pi. There you can run sql file you can find under here to get the database.

the important tables in the database are for the people playing and the sensor data stored in the table 'spel'. That saves when the game starts and ends, the amount of times you hit the hotzone and time played. This all is used to get the scoreboard of the 10 best games played.

Setting Up Sensors and Site

In the Github Library you can find all the code you need to make the sensors and motor work. You can also find all the code to make the website work and interact with the game.


A little info about the code:

The game starts when the ball rolls next to the ldr, so it gets darker. The ldr detects this and starts the game. You can change the intensity of the ldr to perfectly fir your lighting situation. I put it on 950, because that worked well where I built it, but it could be different for you. You get points for every second that you keep the ball 'alive'. When you hit the pressure sensor, aka, the hotzone, you get extra points and the servomotor stops turning for a bit. When you eventually lose, the ball rolls next to IR-sensor and that's how the game knows when you lose.

Making the Phisical Game: the Box

286049350_1549659868762090_2192512003222529631_n.jpg
281399304_3116995925232948_6899540601597081531_n.jpg

The first step of making the game, is making the box itself. I based my design of of this video. Only i used wood instead of cardboard and made the end a little higher, so it could fit the lcd-screen. I was lucky, because i had a friend with a woodcutting machine, but it is possible to cut out the shapes using a jigsaw.

Begin by cutting out the sides, the back, the front and the main ground plate. Before connecting everything, make a hole in the back for the lcd screen. Now connect everything with nails or wood glue. Make sure you have an edge of atleast one centimeter on the sides.

After that, its tome to drill some holes! You need a couple holes in the shape of a triangle to put the sticks in and some holes for the motor and the sensors. On the sticks, put about 3 rubber bands each, so the ball can bounce off of it. Make sure you have some big holes at the end of the box to put al of the power cables and other cables through.

The last and hardest part to make, is the mechanism for the flippers. In theory, it is not that difficult. The sticks you press turn a block and a rubber band pushes that block back. On that block there is a stick with the flipper on the end of that. Make sure that the sticks on the side are really well glued on the blocks, so they don't fall off.

Combining Everything

286465407_797764261215014_6716359573284573817_n.jpg
285660399_393748009443507_6004975840636308472_n.jpg
286648808_715189419733237_1699536235195636335_n.jpg

After the box is done, we can begin putting everything together. You can attach the raspberry-pi in the middle with some small screws. Just make sure you don't put them in too deep, otherwise they're going to stick out of the plate at the top. You can just remove the protective layer of the breadboards and just stick them into the box. Put the ldr in the side on the left of the box, just after the launching mechanism. You can put the pressure sensor where ever you like. I put it in front of one the triangles. You might have to make another hole at the front to slide the IR-sensor into. It has to be sideways to see the ball. The hole you made for the lcd screen should be the perfect size for you to just push it in. For the motor, you can stick a little stick to it, using the glue gun. Put the stick through the hole you made for it and glue a little piece of wood to the stick. After all of that is done, you can top it off by sticking some nice stickers on it!