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
}
}
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
}
}
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!