Coin Change Machine - Can`t quite find the code problem!

You could break out of the loop after a few minutes. The last coin wouldn't take that long. :)

Hi Guys

Sorry for the slow reply but I want away for a few days. Ive now got it working and you were absolutely right, there was an electrical problem. I dont understand electronics but for whatever reason, when the hopper was dropping LOW pulses on pin 3, pin 2 at the same time was picking up HIGH pulses (spikes?). Consequently, it meant that it was counting fake pulses from the coin selector and dispensing more coins - a bad spiral !! Only if the number of spikes did not equal one of the dispense case switches did the loop stop.

Not having a clue about electronics, I got around this in the code by resetting the CoinPulsecount after dispencing. If you notice there is a weird delay in there - this is because for whatever reason, there are still a few spikes and I have to wait that delay(180) before resetting the coinPulseCount otherwise I still read phantom pulses.

Thanks a lot for your help. If anyone has any ideas how to correct this electronically I`d be interested to know.

Chris

Did you try my suggestion in reply #18?

A snubber diode over the dispenser might reduce or eliminate the spikes.

can someone teach me how to build coin changer step by step? im new here i already have coin hopper but i dont have arduino parts yet.