Coin counter

Hello guys...

So I have a new project I am working on. I am collecting coins and would love to use my arduino uno to count the coins. I will have them sorted into piles of quarters, dimes, nickels and pennies already. I am going to build a small chute/funnel to push the coins through. as they go through one by one I would like to count them. I am planning on using a photoresistor on the bottom side and an LED on the top side. I have checked into the "StateChangeDetection" code and that doesn't work for my setup because if a coin would stop right where the photoresistor and LED are it would continue to count. Im sure there is a way to modify this code but I can't figure it out. Could someone help me or point me in the right direction! Thanks in advance!

Firstly you need to deal with using an analog sensor like a photodetector by adding
hysteresys - two different thresholds. Otherwise you'll get multiple transistions when
on the boundary of coin/no-coin, due to the noisy nature of analog signals. The technique in
StateChangeDetection is basically the way to go, but you have to arrange the conditions
for changing state to take hysteresis into account.

This kind of problem crops up with automatic lighting which should come on at dusk - you don't
want the system to trigger everytime a cloud goes past at sunset, or for the light itself to trigger
itself switching back off again, so the threshold to switch the lighting on is set much darker than
the threshold for switching it off at dawn.