Coin Slot to Arduino... Need Help. What to do?

Hey guys, been doing one of the project in instructables w/c is this

Interfacing a Coin Slot to a Arduino. Read and done the instructions provided in the project. But there seems to be a problem bec. i can't seem to get the desired output.

I have a Coin Slot w/c was already set to 3 different types of coins (P1, P5.00, P10.00)(Philippine Coins)
Set it up according to the instructions of the project, "COIN" white wire connected to pin2 (interrupt pin 0) of the arduino, common ground connection of the arduino and the coin slot (12V), and for an easy way to see the output i put up 3 LEDs on pin8, pin9, and pin10.

This is the code i used, (modified)(original comments still there)
const int coinInt = 0;
//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.
volatile float coinsValue = 0.00;
//Set the coinsValue to a Volatile float
//Volatile as this variable changes any time the Interrupt is triggered
int coinsChange = 0;
int OneLed = 8;
int FiveLed = 9;
int TenLed = 10;

//A Coin has been inserted flag

void setup()

  pinMode(OneLed, OUTPUT);
  pinMode(FiveLed, OUTPUT);
  pinMode(TenLed, OUTPUT);

//Start Serial Communication
  attachInterrupt(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 + 1; 

//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
   if (coinsValue == 1)
       digitalWrite(OneLed, HIGH);
       digitalWrite(OneLed, LOW);
    else if (coinsValue == 5)
       digitalWrite(FiveLed, HIGH);
       digitalWrite(FiveLed, LOW);
    else if (coinsValue == 10)
       digitalWrite(TenLed, HIGH);
       digitalWrite(TenLed, LOW);

//Print the Value of coins inserted
  coinsChange = 0;

Rather than using microsoft express, i wanted to use simple LEDs on pin8, pin9, and pin10 to indicate if the program read the input correctly.
after doing the wiring, and coding in the arduino, i tested to see if it would work.
NONE of the LEDs light up after inserting coins on the coinslot.
Need Help! :X

sort by: active | newest | oldest

how to program a coin slot using micro controller connected to pc

what are the codes for the coin slot machine operated by guizdino v4.1 connected to pc

bwrussell4 years ago
It might be staking 2 else..ifs but even then it should still work at least for the 1.00. Outside of that, like Steve, I assume that the pulses are not working correctly. I would maybe start by putting the serial write back into the end of the code and print the coinsValue variable. If the Arduino can print the correct coin value to serial then you know the issue is in the LEDs wiring or code.
Not having used a coin slot the code is a little confusing but I'm guessing that the coinsValue variable is wrong (likely high by 1) so seeing what the arduino has for that value in the end should help. Also you don't need that to be a float do you since there are no fractions of dollars? Changing that to an int could simplify things and maybe work the bug out.
Same mech as the original 'ible ?

Are you sure the LEDs are wired right ?

Gedon (author)  steveastrouk4 years ago
the coin slot is different:

checked if the LEDs are the problem, tried blinking program, the LEDs are working fine
Is it programmed for coins already ?
Do you have the manual ?

The notes I've seen say it can have an RS232 interface.

Gedon (author)  steveastrouk4 years ago
Yes it is already programmed for 3 types of coin
P1.00 - 1pulse
P5.00 - 5pulses
P10.00 - 10pulses

i can't seem to find the manual,
never thought it had one in the first place,

tried searching for one but ended up in a lot of useless sites

Simply put:
What i want is that when it receives -
1pulse, 5 pulses, or 10pulses, 3 LEDs as output will be HIGH with the corresponding input pulse, (1pulse = LED1 High, 5pulses = LED2 High, 10pulses = LED3 High)
Get a scope on the output pins of the selector, and see if it DOES generate pulses.

Just try experimentally changing the interrupt from rising to falling.