Good evening to all of you! I have to implement a vending machine in a project and i want a helping hand on the programming part. In a past post (in the sensors section) i tried to make my own acceptor using some tcrt5000 sensor, but it failed at some point, so i decided to buy a coin acceptor (CH-926).I have already programmed the coin acceptor for 4 coins (10cent,20cent,50cent & 1euro), so i programmed it with this way: if a 10cent coin is inserted, it will give 1 pulse as an output signal, 2 pulses for a 20cent coin, 3 pulses for 50cent & 4 pulses for 1 euro. I have solved everything except from displaying the coin value on an lcd 16x2. I inserted the pin “coin” of the coin acceptor in pin 2 of arduino uno (pin 0 for interrupts).In the code i have posted below, the only thing i’ve achieved is to display the number of pulses in the lcd but i want to convert it as a coin value. I tried to do in the interrupt coins = millis(); so i would read the length each pulse, when a coin is inserted, in milliseconds but it didn’t work.Any ideas?
Thanks for your time!
coin acceptor.txt (737 Bytes)