Introduction: Pinball Machine With Raspberry-pi

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

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)

Step 1: Planning the Play-area

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.

Step 2: 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.

Step 3: Building the 'box'

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)


Step 4: Wiring the Sensors

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.

Step 5: 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.

Step 6: 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