Great code @Skipped, thanks! Love the fact that you commented so well and that it worked practically out of the box.
At first the behaviour was erratic, but once I added:
pinMode(2, INPUT_PULLUP);
to setup(), to turn on the pull-up of D2, it worked perfectly.
When you turn on/off the coin acceptor there is noise on the COIN line, so you may need to wait and reset credit after powering up the Arduino, to avoid generating credit due to race conditions (especially if you use different power supplies for the Arduino and the acceptor).
I'm using it on a vending machine I'm making. Will share on releasetheinnergeek.com when done.
Slot Machine Currency Validator Not Giving Credits Sdat
Bill accepter recognition technology is very sophisticated and relies on a number of banknote characteristics that are quite subtle and generally unknown to the general public.