Testing a Coin Acceptor. Coin pin just won't work

Hi there!
After quite a long time I've needed to service my project - coin acceptor with a "phone" that play some wav files. Coin acceptor gave in and there isn't the same model available at the moment.

So I've ordered a different one, instead of 6 coin ( DG600F) I've settled with 3 coin acceptor (CH-923). But it should be fine the distributor said - the wiring seems to be exactly the same. With some extra switches to control the pulses on the new one.

I've managed to set it up easily. BUT - I cannot get anything out of that COIN pin...
Tried a simple sketch to test the coin acceptor - no luck. I've even tried some digitalWRITE to see if anything changes, still the same output. I am using MEGA 2560 to test it instead of DUE, but for this case it should not make any difference, at least before I am playing with audio shields.

My code:

const int coinInt = 14;
//Coin pin in this case - 14

double coinsValue = 0.00;
//Set the coinsValue to a Volatile float
//Volatile as this variable changes any time the Interrupt is triggered
int coinsChange = 0;
//A Coin has been inserted flag

void setup() {
  Serial.begin(9600);
  //Start Serial Communication
  attachInterrupt(digitalPinToInterrupt(coinInt), coinInserted, RISING);
  //If coinInt goes HIGH (a Pulse), call the coinInserted function
  //An attachInterrupt will always trigger, even if your using delays
}

void coinInserted()
//The function that is called every time it recieves a pulse
{
  coinsValue = coinsValue + 0.10;
  //As we set the Pulse to represent 5p or 5c we add this to the coinsValue
  coinsChange = 1;
  //Flag that there has been a coin inserted
}

void loop() {
  if (coinsChange == 1)
  //Check if a coin has been Inserted
  {
    coinsChange = 0;
    //unflag that a coin has been inserted

    Serial.print("Credit: ");
    Serial.println(coinsValue);
    //Print the Value of coins inserted
  }
}

My schematics:

If anyone is having any ideas - please help. Thank you!

Make sure the 12V and G rails are continuous; many breadboards divide them in half. Use a VOM at the coin counter to make sure it sees 12V.

Interrupts can only be used on certain pins. The pins that can be used are different for different models of Arduino.

Check at arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/ to see whether the pin you selected to use is one of them.

Thanks JohnLincoln! I thought you've just found a solution.
Sadly I've tried to set pin 2, 18, etc. as interrupts - it's same (or similar) outcome.

It might be the wiring also. Now I am starting having some uncontrollable interrupts when using proper pins from time to time (Credit value keeps rising in Serial monitor).

BTW - the breadboard wiring there is for illustration purposes only. I have connected all DC12 + GND wires next to each other to not have any problems.

const int coinInt = 14;//Coin pin in this case - 14 arduino mega
float coinsValue = 0.00;

void setup() {
  Serial.begin(115200);
  pinMode(coinInt, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(coinInt))  //Check if a coin has been Inserted
  {
    while(digitalRead(coinInt));
    coinsValue = coinsValue + 0.10;

    Serial.print("Credit: ");
    Serial.println(coinsValue);
    //Print the Value of coins inserted
  }
}

The coin output of those coin acceptors is open collector.
You need to have something to pull the output high.

The simplest way is to use the internal pullup resistor in the Arduino.

Try adding the following line to setup():

pinMode(coinInt, INPUT_PULLUP);

Tested on an Arduino Uno R3 (using pin 2) and a HX616 coin acceptor.

2 Likes

OK. Found the problem. Which was very very silly. Just an incorrect setup of my new coin acceptor (It has negative range of number for pulses).

As observed by feivel2211

For two out of five coin types there was no pulse output.
I finally found out if you define the number of pulses in "P", you have to choose the number without dot. I accidentially chose a number with dot. If you´re coming in negative number range by clicking the minus button, you will get numbers with dot and no pulse is given.

Thank you all for the help though!!! You are the best!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.