hello,
i've an coins acceptor and i need to read 3 memored coins (2€ output=20, 1€ output=10 and 0.20€ output=2). I programmed arduino to read data from device COIN wire connected in arduino PIN3.
however when i inserted coins arduino don't display anything on console.
it's something wrong with my program(below)? or it's about the connection PIN?
volatile byte coinPulseCount =0;
byte newCoinInserted;
byte cmd=0;
int opCountPin =3;
volatile unsigned long pulseTime;
void setup()
{
Serial.begin(9600);
Serial.print("Input on pin ");
Serial.print(opCountPin);
Serial.println();
pinMode(opCountPin,INPUT);
attachInterrupt(1,coinpulse,RISING);
}
void loop()
{
if(coinPulseCount > 0 && millis() - pulseTime > 200)
{
newCoinInserted = coinPulseCount;
coinPulseCount = 0;
}
switch(newCoinInserted)
{
case 1:
Serial.println("0.01€");
newCoinInserted =0;
break;
case 2:
Serial.println("0.2€");
newCoinInserted =0;
break;
case 3:
Serial.println("1€");
newCoinInserted =0;
break;
}
}
void coinpulse()
{
coinPulseCount++;
pulseTime = millis();
}