This is a reply to a comment on YouTube. I had commented on a Ben Heck video entitled "Build Your Own Pinball Machine," and in the comment I left a link to a video of a pinball machine that I made. He commented back asking me if I would post to the forum with more information about the project and how it was made, so here it is.
This is the machine I built, and it's actually pretty simple. It uses an old pinball machine, an arduino, and a computer to make an older pinball game programmable with a modern computer. The arduino is connected to the playfield so it can read the switch presses, operate the lights, and fire the coils. Connecting the arduino to a computer allows the game to be programmed.
The arduino sends data to the computer through a USB cable telling the computer when a switch has been pressed. The computer can then send data back to the arduino telling it to turn different lights on and off. The arduino provides an interface between the computer and the game board. It allows the computer to know what's happening on the board, and operate the lights when needed.
Connecting an arduino to a computer is easy, but connecting it to a pinball playfield is a little more complicated. Although it's not as difficult as you might expect. The arduino really only has to accomplish three tasks. It needs to read switch presses, turn lights on and off, and fire the coils used on the pop bumpers, flippers, and so on.
Turning lights on and off with an arduino is pretty easy to do. Lighting an LED is very often people's first project with an arduino. Although it's possible to operate the game board's original lighting with an arduino, the simple solution is just to replace the game's lighting with LEDs. I used LEDs I got out of a set of LED flashlights, and they worked just fine.
Reading the switch presses is not that difficult to do either. The arduino already has libraries to operate keypads, and the game board is really no different than a very large keypad. You just connect the arduino like you would to any key pad, and tell it what size it is. The arduino can then read key presses to send to the computer or fire the coils.
To fire the coils the arduino needs to be able to provide the fifty volts of DC current used to power them. The arduino runs on five volts. It certainly can't provide the power itself, so it needs to switch an existing fifty volt circuit on and off. This can be done using transistors. Once the coils are wired with power, the arduino can use a set of transistors to turn them on or off.
Originally I thought to use the game's original power supply board to provide the fifty volts of DC current, but I ended up making my own circuit that worked just as well. To get fifty volts DC from a standard outlet, you first need to get the correct amount of voltage, then convert the voltage from AC voltage to DC voltage.
A power transformer can be used to get the correct AC voltage, and a bridge rectifier can be used to convert it to DC voltage. These two components will provide fifty volts DC, but providing this current alone won't be enough to power the coils. The coils need a large discharge of energy all at once to operate. So a large capacitor is added to the circuit.
The capacitor will store energy and discharge that energy when it is grounded. Grounding the capacitor through a coil will cause it to fire. Placing transistors on the ground line of each coil will allow the arduino to control which coil is grounded to the capacitor and when it's grounded. This allows it to control which coils have power and when they have power.
Since the arduino can read key presses, the coils can be set to energize whenever a certain key is pressed. When the left pop bumper switch is hit, the arduino will ground the left pop bumper causing it to fire. After hitting the ball the coil can then be switched off to prevent it from over heating. Most coils will be set to energize momentarily whenever a certain key is pressed.
No data needs to be sent to the computer for the arduino to operate the coils, with the exception of the ball return. The ball return doesn't need to fire immediately when it's switch is pressed. It just needs to tell the computer when the ball has drained, and then the computer can decide when to fire the coil and serve the next ball.
Sending and receiving data between a computer and an arduino requires the use of some kind of programming language. You can use the serial console in the arduino development software to send commands to the arduino, but you would never be able to create a game that way. A programming language with support for serial communication is needed to create an actual game.
I used two different languages to program my game and they both worked equally well. The first version of my game was programmed in C# and it was certainly capable of what I needed it to do. It needed to talk to the arduino on the serial port and monitor the key presses, send commands to operate the lights, as well as play sounds and draw the scoreboard.
Although C# was capable of doing all this, I did find it difficult to overcome basic obstacles such as having two sounds playing at once, and adding background music. C# is more suited for creating applications than it is for making games. Later I switched to the Python programming language and used the Pygame library. It worked just as well as C# except it was a little easier.
I'd recommend anyone attempting this project to use Python and the Pygame library. It's not as powerful as C# but it can get a simple game up and running much faster. Pygame is pretty easy to learn, and there's a lot of documentation on it so you aren't likely to get stuck. Especially if you keep it simple. A basic display and a few sounds isn't difficult to accomplish.
Considering the complexity of older pinball games I think this is a pretty simple project. The power supply board only contains two components, and the driver board only contains one transistor for each coil. Plus the game can be run and programmed on any computer with a USB port. What could be more simple?
This might not be the most impressive project ever, but it gets the job done. I'd recommend this project to anyone looking to make a pinball game of their own. Trying to build a game with the same components used on older games is way too much work, and is well out of reach of the average hobbyist. This project however, only requires some experience using an arduino.