attachInterrupt(0, coinInserted, RISING) at pin 2, using Arduino Uno
Good day, Im new in arduino and trying to build carwash vendo machine to support my family need, Hope you can help me with the issues i'm facing using "attachInterrupt" code for my coinslot...My problem and my question is, why whenever my system detect loud noise, my system adding up coin credit, I experienced it when one of my colleague testing my carwash and start his motor after, around 2 meters away from my vendo it will contiously adding up a credit, please help.
Thanks
Your circuit is picking up interference. You've probably got some mistakes in the circuit. Or maybe there is a mistakenin the code. Nobody here can tell because they can't see any of your project and you did not post any of those details.
How is the coin acceptor wired to the Arduino? Do you have a pullup or pulldown resistor connected to pin 2? Post a link to the coin acceptor's datasheet.
But your attach interrupt line is set to RISING and the internal pullup resistor is fairly high impedance, so may be picking up EMI and false triggering. Try connecting a 4.7k pulldown resistor between pin 2 and GND. Is the idle state of the coin acceptor output HIGH or LOW?
Coin Acceptor powered by 12 volts and Ground thru AC/DC Power Supply... and the COIN Signal fron Coin Acceptor I connect it Directly to Pin 2 of Arduino Uno
I don't understand the way of powering up the coin acceptor...
But base on my understanding, I'm just using 12V and Ground to power up the Coin Acceptor.
By the way, Coin Acceptor has 4 pin
12V
Coin
GND
Counter
We're just using the first 3 pin as normal practice by others
I can answer that question for 21dream2come, in case he doesn't know the answer.
The coin output of those coin acceptors is open collector / open drain. From the code in post #3, I can see that 21dream2come is using the internal pullup on the coin input.
The coin acceptor is working normally in terms of accepting coins...
my problem is whenever there is a loud noise on the background the pipe of the motor to be specific it continous adding up the total credit coins ups and down actually and I don't understand why?
Those coin acceptors have a selector switch (not labelled on the picture in post #9) that is used to select whether the coin output transistor is 'normally closed' or 'normally open'.
Thus you can select whether the output is low and pulses high when a coin is validated, or high and pulsing low.
The good news is that both types of pulse have one rising edge, and one falling edge.
See the instruction sheet for a similar coin acceptor below for details: HX-616 Coin Acceptor.pdf (204.1 KB)