Hi guys need help with my code, I am trying to create a project that use Universal Coin Acceptor (CH-9260 that can program every coin has a pulse) with Arduino and send serial comunication to Visual Basic
I trying to read the pulse of every coin I inserted and print what type of coin inserted
sample pulse set on the "Universal Coin Acceptor "
coin 1 = 1 pulse
coin 2 = 5 pulse
coin 3 = 10 pulse
wiring!
coin slot pin coin = pin 2 arduino
goal!!
sample output serial.println every coin inserted, just on read what type of coin inserted
coin 1 = coin 1 Inserted
coin 2 = coin 2 Inserted
coin 3 = coin 3 Inserted
this is my code that I got form a youtube video(no code provided just pause and write the code), already verify no error but still blank on serial print.
YT Video by: craynerd
I know this new topic is old, but some of them is using arduino with LCD, I am just using arduino nano and coin acceptor. If you have any idea or code line good an realiable, please help me
const int coinpulse1 = 0;
int coinPulseCount = 0;
int newCoinInserted =0;
volatile unsigned long pulseTime;
void setup()
{
Serial.begin(9600);
pinMode (2,INPUT_PULLUP);
attachInterrupt(coinpulse1, coinpulse1, RISING);
}
void loop()
{
if (coinPulseCount >0 && millis()- pulseTime > 200)
{
newCoinInserted = coinPulseCount;
coinPulseCount = 0;
}
switch (newCoinInserted)
{
case 1:
Serial.println("coin 1 Inserted");
newCoinInserted = 0;
break;
case 5:
Serial.println("coin 2 Inserted");
newCoinInserted = 0;
break;
case 10:
Serial.println("coin 3 Inserted");
newCoinInserted = 0;
break;
}
}
void coinpulse()
{
coinPulseCount++;
pulseTime = millis();
}