Pinball Machine With Raspberry-pi

by matthias morsa in Circuits > Raspberry Pi

1223 Views, 1 Favorites, 0 Comments

Pinball Machine With Raspberry-pi

355488344_219949947587600_3372882845932627690_n.jpg

For a school project in my first year of MCT howest Belguim, i was tasked to make something useing all the lessons we have had over the two semesters.(database,sensors and interfacing,python,backend/frontend,...). After giving some ideas a pinball machine was chosen by the teachers.

so what was my plan? Making a 2/3 size pinballmachine using one sensor i had learned troughout the year. and at least two new sensors. also a dedicated database and website to show the data from the database. i obviously needed to program and make most of the project myself.

you can use these plans to make the same pinball machine as i did or use them for inspiration.

Supplies

foto.jpg

raspberry pi 4b

breadboard + breadboard power supply

10 inductive proximity sensors (LJ8A3-2-Z/AX-5V)

2 sets of opto sensors (A-14231-2)

3 in 1 pinball target

1 buttons (to start py,type name)

1 mpu6050 (or just accelerometer)

wood and screws

carpeting tools

i payed a total of 192.43 (price can be more or less depending on what materials you have)

Planning the Play-area

desing v0.0.png
desing v0.5.png

For the play area it is important to know where you want certaint things to go. Because what kind of target you want defines the sensor you will use.

In the above plans you can see i have a triangle shaped array of targets. These targets are flush with the play field. the three targets on the left are switches you hit with the ball. the right side can either have two more targets to hit or a horseshoe ball guide. in this ballguide we wil be putting two optical sensors.

You can ofcourse choose other places for the targets or other target types. note that the red bottom circle will not be used for my machine.

Getting the Sensors and Testing Them

Where can we buy these sensors/targets? You have sites like ebay/aliexpress for cheap common targets. but also dedicated websites for pinball targets. you wil find what i used for my target in the bom file but here are some examples

inductive sensor,single-target (note that i am from belguim so if you live in america pinball parts will be easier to get)


Testing the sensor can be done by using the datasheets or tutorials found on sites like youtube. Sometimes you cant find the exact part for a tutorial, In that case try to find the used components for example:

A-14231-2 (williams opto set):

We can see the first board has some kind of led but no resistor, so we can just make a connection with a resitor in series. The second board uses some kind of npn transistor and only the emiter and collector are able to be connected. We can connect this like a button to our raspberry pi.

Sometimes we get easier images like for the lj8a3-2-z/ax (inductive proximity sensor):

SIG = singal pin (high or low) indicated by a black wire

VI = voltage in (5V) indicated by a brown wire

VO = voltage out/ground indicated by a blue wire

The mpu6050 is a bit harder to use but there are alot of librarys you can use (or make your own):

but this is the method of getting data out of the component

With the I2c adress we can ask the mpu6050 to give us the data from two certain memory slots.

we then have to use some code to stick these bytes together. But the order is important (double check on the datasheet)

After sticking these togheter you can just read it as a float for the directional speed.

you will find my code for testing the sensors and the librarys in the attached files.

Building the 'box'

353175202_1368822290642964_6100366282113720961_n.jpg
354476533_591378872981177_1572312634403979233_n.jpg
354664474_283788650710773_6386464128249476115_n.jpg
348911718_1292528958333554_1426656353028906_n.jpg
348361420_634939498697356_8106441231128817992_n (1).jpg
352537988_938536717421733_6531770777973070111_n.jpg

To be able to play in the play area we need to have it at an angle downwards to the player. And also some walls to keep the ball from rolling away. i first created a box

2 panels with a sloped plank inside (longside)

1 with a hole so the ball can get out (short side)

1 just plane (short side)


Wiring the Sensors

354034919_101198486349847_7933111468477791524_n (1).jpg
breadboard_final.JPG
schematics_final.JPG
352549858_1335136817216702_2982119236308329393_n.jpg
354806514_301960329068938_2132024556650224518_n.jpg
354780586_642625224407073_1689373884872927826_n.jpg

the next step is to wire all the sensors to the playfield + the raspberry pi

i used screws and zipties to hold the wires together so i cankeep them organized. and also to secure the breadboards or other components. if you can u should ofcourse use the screw holes made for securing these up walls.

Creating the Game

After testing the sensors and using them you can create the program for how you want to play the game.

You can choose to make all sensor give different points or even make it so that you have to unlocks some sensors before they give points. Its all up to you to create the rules of the game.

i have it set up that all sensors are active and give different amount of points but the proximity sensor only work once.

Make a Database(optional)

As part of the assingment i needed a website and database. both code also are in the included files. the database is made in MySql and the website uses html,javascript and scss