attachInterrupt(0, coinInserted, RISING) at pin 2

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.

Sir, Idid not use any pull up nor pul down resistor to connect coinslot to the Arduino,

pinMode(coinSlot, INPUT_PULLUP);

Allan Universal Coinslot 1239 Promax

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?

The web page you posted tells us nothing about the product's electrical workings. Post a link to it's datasheet or users manual.

I use DC12 to positive 12V, GND to Ground and COIN as signal to Pin 2

What is the voltage between COIN and GND? How are the GND and COIN wires connected to Arduino?

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

So, you are putting a 12V signal on a 5V input pin?

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

Sorry not enough information for me to help, maybe one of the other members can. Good luck.

Thank you so much for your time sir...

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.

So it doesn't put 12V on a 5V pin.

1 Like

Thank you sir for helping out,

Am I wrong by using "attachInterrupt(0, coinInserted, RISING) at pin 2" or do i need to use full down resistor to solve the issue? please advise

OK, so the OP needs "FALLING" in the attachInterrupt(). Right?

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)

1 Like