Hi everyone,
I recently bought a coin acceptor
https://s.click.aliexpress.com/e/_DCOgK57
and I'm having trouble integrating it with my Arduino. When I connect the device to a regular LED, it flashes a few times, which seems to indicate it's working. However, when I connect it to the Arduino and monitor the serial output, I see a constant rise and fall in voltage.
Has anyone encountered a similar issue or knows what might be causing this? I’m wondering if it’s a wiring or code issue, or maybe something with the power supply. Any help would be greatly appreciated!
Thanks!
Disclaimer: no experience with coin acceptors.
Maybe your coin acceptor has a simple switch or an open collector / open drain output. In these cases you need a pull-up resistor.
If so, you can use below in the setup() function.
pinMode(thePin, INPUT_PULLUP);
I do not know if your coin acceptor came with a manual and a schematic of the internals; if yes, I suggest that you post the schematic here.
1 Like
Posting the code would be a good idea, and the wiring.
1 Like
Here is the instruction manual for that type of coin acceptor:
HX-616 Coin Acceptor.pdf (204.1 KB)
Yes, you are correct sterretje, so using INPUT_PULLUP is the way to go.
There is a selector switch that determines whether the open collector output is normally low with high going pulses, or normally high with low going pulses.
1 Like
Thanks for the suggestion! I'll definitely consider what you've mentioned regarding the pull-up resistor and check if my coin acceptor might be using an open collector/open drain output. It sounds like a plausible explanation for the issue I'm seeing.
At the moment, I can't test it out because the device is not with me right now. Once I have access to it again, I’ll try these suggestions and post the wiring and the code for further help if needed.
Thanks again for the assistance!
You need to power the coin acceptor from a 12V supply.
Make sure that the Arduino GND is connected to the negative terminal of the 12V supply.
Use the techniques shown in the IDE example "State Change Detection" to detect the pulses from the coin acceptor.
Here is some code that will test the coin acceptor:
const int coinInputPin = 2;
const int ledPin = 13;
int coinInputState = 0;
int lastCoinInputState = 0;
unsigned int baseUnit = 5;
unsigned int credit = 0;
void setup() {
pinMode(coinInputPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
Serial.println(" credit");
Serial.print(" ");
Serial.println(credit);
}
void loop() {
coinInputState = digitalRead(coinInputPin);
if (coinInputState != lastCoinInputState) {
if (coinInputState == HIGH) {
digitalWrite(ledPin, HIGH);
credit = credit + baseUnit;
Serial.print(" ");
Serial.println(credit);
} else {
digitalWrite(ledPin, LOW);
}
lastCoinInputState = coinInputState;
}
}
Here is what happens when a 50 pence piece is inserted into the coin acceptor:
The coin acceptor has been programmed to give out 10 pulses when a 50p coin is accepted. Thus the base unit is 5p.
Thanks again for the suggestion. I tried using the pull-up resistor like this:
const int coinInputPin = 2;
void setup() {
pinMode(coinInputPin, INPUT_PULLUP);
Serial.begin(9600);
Serial.println(".");
}
void loop() {
Serial.print(digitalRead(coinInputPin));
}
However, the serial output still shows constant fluctuations like this:
11111111111111111111111111111111111111111111111111111111111111111111110011111111111111111001111111111111111110011111111111111111000111111111111111100111111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100101111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100111111111111111111001111111111111111101011111111111111110011111111111111111001011111111111111110011111111111111111000111111111111111100011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110011111111111111111100011111111111111110001111111111111111000111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101111111111111111110010111111111111111000111111111111111110001111111111111111010111111111101111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100001111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100111111111111111110101111111111111111001111111111111111100101111111111111111000111111111111111101011111111111111110011111111111111111001111111111111111110001111111111111111010111111111111111100111111111111111110011111111111111111000011111111111111110001111111111111111001111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100001111111111111111000111111111111111101111111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100101111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111001111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110011111111111111111100111111111111111110101111111111111111001111111111111111100111111111111111111001111111111111111101011111111111111110001111111111111111001111111111111111100001111111111111111000011111111111111100111111111111111110011111111111111111000111111111111111110001111111111111111011111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001011111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001011111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110011111111111111111010111111111111111100111111111111111110011111111111111111100011111111111111110101111111111111111001111111111111111100111111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110011111111111111111000111111111111111100011111111111111110011111111111111111100011111111111111110001111111111111111001111111111111111100111111111111111110001111111111111111100011111111111111110011111111111111111001111111111111111100001111111111111111000111111111111111101011111111111111110011111111111111111000011111111111111110001111111111111111010111111111111111100101111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100010111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111001111111111111111110011111111111111111010111111111111111100111111111111111110011111111111111111100011111111111111110101111111111111111000111111111111111100101111111111111111001111111111111111100011111111111111110001111111111111111001111111111111111110011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110010111111111111111000011111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110010111111111111111000111111111111111110000111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111011111010111111111111111100111111111111111110011111111111111111100011111111111111110101111111111111111001111111111111111100101111111111111111001111111111111111101011111111111111110011111111111111111001111111111111111100011111111111111111000111111111111111100111111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001011111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100001111111111111111000111111111111111101011111111111111110011111111111111111000011111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000011111111111111110001111111111111111010111111111111111100111111111111111110010111111111111111100011111111111111110101111111111111111001111111111111111100111111111111111111000111111111111111100011111111111111110001111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111011111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100001111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100101111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100101111111111111111001111111111111111101011111111111111110011111111111111111001111111111111111110011111111111111111010111111111111111100011111111111111110011111111111111111100011111111111111110001111111111111111000111111111110111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100111111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110011111111111111111010111111111111111100111111111111111110011111111111111111100111111111111111110001111111111111111000111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000011111111111111110011111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100001111111111111111001111111111111111101011111111111111110011111111111111111001111111111111111110001111111111111111000111111111111111100011111111111111110010111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000011111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111001111111111111111101011111111111111110011111111111111111001111111111111111110001111111111111111010111111111111111100111111111111111110011111111111111111100011111111111111110001111111111111111000111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001011111111111111100001111111111111111000111111111111111101011111111111111110011111111111111111000011111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110011111111111111111010111111111111111100011111111111111110010111111111111111100111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001011111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100111111111111111110100111111111111111001111111111111111100111111111111111111001111111111111111101011111111111111110011111111111111111001111111111111111100001111111111111111000111111111111111101011111111111111110010111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001011111111111111100001111111111111111000111111111111111101011111111111111110010111111111111111000111111111111111110011111111111111111010111111111111111100111111111111111110011111111111111111100111111111111111110001111111111111111001111111111111111100101111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110011111111111111111010111111111111111100111111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100111111111111111111001111111111111111100010111111111111110001111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100101111111111111110001111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111001111111111111111100011111111111111110011111111111111111001111111111111111100001111111111111111000111111111111111101011111111111111110011111111111111111000111111111111111110001111111111111111010111111111111111100111111111111111110000111111111111111100011111111111111110101111111111111111001111111111111111100011111111111111111000111111111111111101011111111111111110011111
It seems like the coin acceptor is still sending rapid signals, and I’m not sure why. Unfortunately, the issue persists.
I’ll keep investigating, but if you have any other suggestions, I’d appreciate it.
Thanks again for your help!
No
Your reading (and printing) at high speed. So it will constantly print a '1' till a coin goes through (that's possibly the zeroes that you see), I do not know).
What you might need is a state change detection where you detect a change from a 1 (HIGH) to 0 (LOW).
Have you got a connection between the Arduino GND and the GND of the Coin Acceptor?
The code that you are using looks as though it is more suitable for viewing on the Serial Plotter, rather than the Serial Monitor.
I only had to change the Serial.print to Serial.println to get the following:
4 pulses from a 20p coin.
I prefer to have the NO/NC switch (3) in the NC position.
That way the output is normally pulled low , and goes high when coins are accepted.
If you have the switch in that position, and the output is high it is most likely to be a missing GND connection.
1 Like
Thank you for your input!
My coin acceptor is currently set to NC (Normally Closed).
The output I’m seeing is without inserting any coins, which indicates that the signal is unstable even when idle.
If you have any other suggestions for stabilizing the output in NC mode, I would appreciate it!
Thanks again for your help!
Make sure that you have a connection between the Arduino GND and the coin Acceptor GND.
The plotter always looks like this regardless of the voltage level it has
I tried connecting the 3.3V output to the input and the plotter did not change
The plotter shows above 0. I don't understand how the voltage level reached it
It shows the same level even if no wire is connected
I tried to connect the coin device to Arduino's GND, but that way it didn't turn on at all
The coin machine only works if I connect it to the GND of its cable
const int coinInputPin = 2;
void setup() {
pinMode(coinInputPin, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
Serial.println(digitalRead(coinInputPin));
}
I was referring to what @JohnLincoln said here
John, from Lincoln:
The code that you are using looks as though it is more suitable for viewing on the Serial Plotter, rather than the Serial Monitor.
I only had to change the Serial.print to Serial.println to get the following:
4 pulses from a 20p coin.
The DC12V (red) and GND (black) wires of the coin mechanism need to be connected to the positive and negative terminals of a 12V power supply. This will enable the coin mechanism to be powered up.
The COIN (white?) wire needs to go to the Arduino digital pin 2.
You then need an additional wire between the power supply GND and the Arduino GND pin.
The coin mechanism black GND wire has to connect to both the power supply negative terminal and the Arduino GND.
1 Like
I was referring to the code that you posted in post #7 , after I had supplied code in post #6 that does what LarryD is telling you to do.
earduinonew:
The plotter shows above 0. I don't understand how the voltage level reached it
It shows the same level even if no wire is connected
The use of INPUT_PULLUP is making the input high (1).
The input should be pulled low (0) by the NC coin output of the coin acceptor, but this will only happen if the Arduino GND is also connected to the coin acceptor/power supply GND.
system
Closed
April 25, 2025, 6:18pm
19
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.