My own Pinball Machine

Hello folks,

I am currently working on a my own wooden pinball machine from scratch. I have made the flippers work manually with actuators and springs. The launcher is also driven by hand with a spring. I have no physical pinball parts like machinery but the actual ball and perhaps the main mechanics.

What I'm looking for as a final is a fully working pinball machine. In a list I want:

A (n) number of LED's for assign to targets.
A (n) number of switches to assign to hit targets.
A (n) number of LED's for playfield atmosphere.
A LCD screen to visually see score, ballcount, play information. || A number of 64x64 square leds set in line to have these visual effects. (a DMD imitation)
A controller for a (n) number of servos to reset dropped targets.
Being able to playback sound effects and background audio (while not blocking the detection of switches and the turning on and off of leds)

What I currently have:

Arduino Uno R3.
Pololu micro maestro (6 channel servo controller)
7 segment 8 digit LED display.
Small usb powered speaker (with a line in)

I still need to get a sd card reader to be able to use wave files, for now sounds are tones.

What I currently know to do:

  • I know how to turn on and off leds.
  • I know a bit how to use the micro maestro as stand alone. (not yet know how to let Uno control it)
  • I know a bit how to use the 7 segment 8 digit LED display. (I got numbers, counter and some letters displayed)
  • I know a little bit how to use millis(); to help in multi-tasking.
  • I know a little bit now how to use tone();

In a way it should be enough to get a working pinball machine. some more pieces are needed but considering the size of my project, I am going to run out of pins on the Uno for all these actions. I could consider the following:

Adding arduino mega to expand on available pins for all actions required?

Set it up in a master/slave configuration with the uno and the micro maestro? (they can still operate their own cores and their own sketch?)

To help in multi-tasking I was thinking to have one arduino handle the audio, and the other to handle the display, the leds, the switches and communication with the maestro?

My question:

Is this going to be a sufficient setup or do I need a different approach to achieve this?

This sounds like a fun project, and it looks like you have most of what you need already. An Uno might not have enough pins for you: get a couple of Megas so that you can destroy one by accident.

Your plan does sound VERY ambitious, so maybe break it into smaller projects before diving in to a full-on pinball game.

I suspect you're going to have some issues with multitasking and tone(), especially if you want layered audio.

Having background music and simultaneous bleeps and bloops when the player hits targets won't (to my knowledge) be possible using tone(); it's not a polyphonic audio system.

You might look into these DFPlayer modules to handle your audio. I've had good results using multiple DFPlayers for different channels of sound; one for background music and one for sound effects.

Or look into the various and sundry MP3 shields available for arduinos, they will be helpful in mixing audio.

Having both background music and sound effects when hitting targets would be just like regular pinball machines.

The not enough pins on the uno for this huge project was something I suspected early on. Having 5 targets on the playfield would require 5 pins for the detection and 5 pins for the LED tree connected to said targets. that would not leave a lot of free pins to do the other things. But for prototyping the uno is fine. I'm gonna order some mega boards then.

They are capable of working for themselves even if you daisy chain them as master/slave/slave? That would be helpful for multi-tasking? I suspect it would.

I got a lot to learn about the timing yet with what I currently can do I can see the arduino is stalling if you play a long melody in tones (it still has that delay added.) and add to that counting and displaying at the same time.

I'm looking at those DFPLayer modules but I can't find these locally (yet) The store I went to does not have a lot of shields in the audio class, unless they are 40~60 euro a piece. I have to keep looking for them. I have read in other people projects using arduino's to run real world converted pinball machines with and they keep saying the mp3 shields are very slow in their reaction to required triggers. (maybe they use too big files? loading times are not fast enough?)

I was thinking that the tone beeps are quicker since they don't need loading times. Even converted wave files to header file would be faster than loading files from an SD card??

I don't want to throw money away at a mp3 shield that can only start playing audio long after an action has taken place on the playfield, that would just confuse a player.

Side note: Why teach newcomers to use the delay function if it's such a bad thing to be using when you start to want to do two or more things at the same time????

Even if using millis() or some FSM (finite state machine) is more complex to learn, I see delay in a lot of examples!

jrodda:
You might look into these DFPlayer modules to handle your audio. I've had good results using multiple DFPlayers for different channels of sound; one for background music and one for sound effects.

Or look into the various and sundry MP3 shields available for arduinos, they will be helpful in mixing audio.

Would something like this be used?

Or something like this?

crazybite:
Would something like this be used?

https://vanallesenmeer.securearea.eu/MP3-speler-met-2W-mono-versterker-via-USB-stick-of-MicroSD-kaart

Or something like this?

WTV020-SD-16P Audio player module - vanallesenmeer

I would stay away from the WTV020's, they use a weird audio format that can be difficult to work with. Can't comment on the other MP3 player.

Looking at some of the photo's I'd think the WTV020 is not made that well. I might get the other one. Looking at the photos of that it's made a lot nicer.

I might just order two then, one for the background music and one for the sound effects when hitting targets, or other trigger events. I could use a Y fork type cable to connect them to one speaker?

Maybe consider a Pi for the audio effects - you can talk to it over serial (don't forget it's 3.3V though) from one of the Mega's ports.

I would consider using a Pi board, but they also cost a lot more compared to the small break out boards.

Last thing that is important is how quick does audio get played if the trigger is sent to play a file?

crazybite:
Last thing that is important is how quick does audio get played if the trigger is sent to play a file?

The DFPlayer's audio playback seems pretty much instantaneous, at least to the meat husk my consciousness currently inhabits.

I've asked the store about those DFPlayer modules, they don't have them yet but they will add them so I can order a few of those.

To detect hits in lanes I was thinking to use 3mm IR sensors (capable to detect within a gap of up to 27cm if something breaks the infrared.) (also available in 5mm)

Could I use these to detect if pinball passed?

It will take about three weeks for the DFPlayer(s) to arrive.

I also got two 4in1 banks of 8x8 leds on order. to make a small DMD with.

Avoid multiple Arduino in the same project. It's a mistake many beginners make, I assume most of the projects they start fail and they give up. Getting multiple sketches which must communicate with each other is very difficult to write and debug.

For extra inputs (ir sensors) and outputs (LEDs), you could use shift registers or I/o expander chips. Sounds like your 8 digit display and your led matrix displays probably use max7219 chip, which communicates with the Arduino via the SPI bus, so it may be easier to stay with SPI bus for your other needs. 74hc595 (for outputs) and 74hc164 (for inputs) shift registers could be used, or you can use mcp23s08 (8 input/output pins) or mcp23s17 (16 input/output pins) which have the advantage of being able to interrupt the Arduino when an input changes, instead of the Arduino having to continually check for changes.

Well, isn't that normal for someone that is just starting to not know about certain hardware and then go try using multiple arduino to achieve their goal? What else are the RX and TX pins good for? They are for communicating with another device are they not?

Anyway I'm on a hunt for those shift registers. I've found a 74HC595 and a 74HC165 I could use them?

It comes as just a IC chip or a breakout. But the other ones I can't find there yet. I guess I can ask them to add to their inventory...

The tx and RX pins are for sketch upload and communicating with the serial monitor. They can be used to communicate with another Arduino, but this makes debugging, correcting and re-uploading sketches very difficult indeed, if not downright impossible. Getting code to run is difficult enough for a beginner, without tying your hands behind your back/blindfolding yourself as well.

74hc595 is ok for lighting LEDs, but you need to limit the current to about 8mA per led. With modern high-brightness LEDs, it is often plenty. But if you want maximum brightness for your leds, look elsewhere.

74hc165 is useful for reading lots of digital inputs, but they are not as intelligent as dedicated I/o chips and cannot monitor their own inputs for changes and automatically notify the Arduino when a change is seen. This means that the Arduino must constantly read the inputs and check for changes itself. Your ir sensors many only be triggered for very brief periods, and I am concerned they may be missed. But maybe I am being overly concerned. If you use the Arduino's SPI pins, the inputs of several 74hc165 can be read very quickly, and the outputs of several 74hc595 can be updated at the same time.

Hmmm how would a led then light up if it only gets 8mA of current? they want 20mA?

Edit: What about this thing then?

If I search google for mcp23s17, I can find them as chips, would these then be the best go get for the job? I'm guessing when you get this chip you can't just connect switches and leds to it without additional components?

I can always try one IR sensor to see if they miss the ball go through, I guess your pointing to the ball that can get quite some speed at times when it goes to fast the IR could miss the detection?

20mA is the max for most LEDs. As I said, many modern high-brightness LEDs are pretty damned bright at 8mA. At 20mA it hurts to look at them. You should try it and judge for yourself if they are bright enough for your machine.

If you do need 20mA for the LEDs, the tpic chip is a good choice. You can put it in a chain with a mix of tpic6b595 and 74hc595, they are compatible in terms of signals.

With mcp23s17 you can connect components pretty much as you would with Arduino digital pins. Yes you can connect switches with no other components (MCP chip has internal pull-ups like Arduino pins do). For LEDs you will still need series resistors. I think the chip can source/sink 20mA per pin. But, as with the Arduino chip itself, you have to check the total current that the chip can source/sink, and plan how many of your LEDs can be lit at the same time.

I might have found a source of information about how to use shift registers with arduino, here:

and here:

and went through it quickly, it seems to explain the usage pretty well? I was wondering, is this the correct way to use them? If so I will learn to use them. (cause the pinball gonna need a lot of switches and outputs)

As for the LEDs mA requirements, the information on the website states:

Dutch:
Product details:

Lens: 3mm Diameter/Transparant/Ronde

Emitting Kleur: Rood Groen Blauw Slow Flash Automatisch

Lichtsterkte: 3000-5000mcd

Kijkhoek: 30 Graden

Forward Voltage/Stroom: 3 V-3.2 V | 20mA

polariteit: Anode (Langer Deel) | Kathode (Korter Deel)

To me it looks like forward voltage is 3V ~ 3.2V and current is 20mA?

Nick's tutorials are excellent.

One thing he does not explain is how to simultaneously read from the 74hc165 and update the 74hc595, which can be a useful technique to reduce the number of Arduino pins required and to make your sketch efficient.

You are correct about the specification of the LEDs. You need more than 3.2V to run them. With a 5V supply, 3.2V will be taken by or "dropped" by the led and the remaining 1.8V will be dropped by the series resistor. The value of the resistor should be selected so that the current flowing through the led does not exceed 20mA. If you use a resistor value which is too low (or no resistor) then more than 20mA will flow and the led will be damaged (it can not protect itself). If you use a higher value resistor, then less than 20mA will flow and the led will be dimmer.

For your leds, the lowest value resistor you should use would be (5-3.2)/0.020 = 90 ohms

The nearest commonly available resistor value above that would be 100R which would give a current of (5-3.2)/100 = 0.018A = 18mA

You can see in Nick's 74hc595 tutorial that he uses 1K series resistors. His LEDs are probably similar to yours and the current flowing will be (5-3.2)/1000 = 1.8mA

This is less than 10% of the LED's maximum current, but as you can see they are still quite bright.

Your led specification says "Slow Flash Automatisch". Perhaps this is an option you can choose when you place an order. But you want your LEDs to be under control of your code, and not to flash themselves, I think.

If also says "Kijkhoek: 30 Graden" or "Viewing Angle: 30 Degrees". For your machine, the player will be standing at the front of the machine, which will have a slightly sloping playing surface and the LEDs there will point upwards, I think. So to make these LEDs appear bright to the player, you want a wide viewing angle, ideally 120 degrees, like these for example.

I could have provided a translation for that, the explaination from the seller (I asked about it in e-mail) is that if you provide voltage to the LED it automatically sequences thru the available colors in X second intervals.

so it's first 3 seconds RED, then 3 seconds GREEN and then 3 seconds BLUE. All that was required to do was give it 3 to 3.2 volts. (if you give it 5 volts a resistor is required) I used an online calculator like this one:

http://led.linear1.org/1led.wiz

to help with calculation of Ohms law to get the right resistor value.

EDIT: from the calculator if you insert 5 volt source, 3 volt forward and 2 mA current you get a result of 1kohm 1/8w (then I can pick the 1kohm 1/4w cause that store won't sell 1/8w ones)

When placing these LED's I need to take into account that viewing angle, otherwise you won't see the led to full potential.

I might have found something that can do the things you mentioned about the MCP chips.

I could not find the 8 bit variant, but I can find mcp23017 i/o expander ic i2c

It's description states you can have input or output. I have to read the manual to see what this can do.

So I can find

74hc165 + 74hc595

MCP23017

What should I pick to use? Re-reading your post about them it looks like the mcp ones are capable of more than the other ones?