Coin Acceptor + Arduino UNO R3 - programing issue

Hello ,

Im new to such thing as electronics , im a photo booth builder

i got the coin acceptor " CH-923 " and i programed it to identify and accept one type of coin " no cash value " and send 1 pulse …

though i have a major problem with the programing …

how can i program the arduino to a accept the pulse from the coin acceptor and turn it into a mouse click ? , Just like that !

i’ll be grateful , thanks for your help .

how can i program the arduino to a accept the pulse from the coin acceptor

That depends on how you have connected the coin acceptor to the Arduino.

and turn it into a mouse click ? , Just like that !

You need the Arduino Mouse board (also known as a Leonardo or Micro).

hey , i ordered the Leonardo once you told me to , and it has just arrived ..

what is next ..

what is next …

You write some code.

And, before you ask, you test the code. Then, you debug the code.

Hey did you manage to write some code? Got stuck with this too.. I never used interrupts before and don't have much time to finish this now.. Any example code?

Thanks!

hy,

try the next code

    /*
      This sketch assumes that coin 1, will return 1 pulse, coin 2 will return 2 pulses, and so on.
     
     Coin values:
     1 = 0.5
     2 = 1
     3 = 2
     4 = 10
     */
     
    const byte coinValues[4] = {
      5, 10,50, 100}; //Coin values goes into this array
    #define pulseTimeout 200        //How many milliseconds there are from the last impulse to the coin is determined (default 275)
    #define actionTimeout 60000     //How many milliseconds before stored credit is reset (default 60000)
     
     
    unsigned long lastAction = 0;   //When last action was made
    unsigned long lastPulse = 0;    //When last pulse was send
    int pulseCount = 0;             //How many pulses we got
    int currentCredit;              //The current credit
     
    void showCredit()
    {
      int credit = currentCredit/10;
      int left = currentCredit % (currentCredit/10);
     
      Serial.print("Current credit: ");
      Serial.print(credit, DEC);
      Serial.print(".");
      Serial.print(left, DEC);
      Serial.println("0");
    }
     
    void setup()
    {
      Serial.begin(115200);
     
      attachInterrupt(0, acceptorCount, RISING); //Digital interrupt pin 1
      attachInterrupt(1, acceptorPulse, RISING); //Digital interrupt pin 2
     
      Serial.println("Coin Acceptor ready");
      pulseCount = 0;
     
      pinMode(13, OUTPUT);
    }
     
    unsigned long tempAction;
    unsigned long tempPulse;
     
    void loop()
    {
      tempAction = lastAction;
      tempPulse = lastPulse;
     
      if (millis() - lastPulse >= pulseTimeout && pulseCount > 0 || pulseCount >= 4)
      {
        if (tempAction != lastAction || tempPulse != lastPulse) return; //Check if interrupt has fired since loop started, wait for next cycle if it has
       
        tone(12, 1800, 150);
        currentCredit += coinValues[pulseCount-1];
        showCredit();
        pulseCount = 0;
      }
     
     
      if ((millis() - lastAction >= actionTimeout) && (lastAction != 0) && (currentCredit > 0) && (pulseCount == 0))
      {
        if (tempAction != lastAction || tempPulse != lastPulse) return; //Check if interrupt has fired since loop started, wait for next cycle if it has
       
        currentCredit = 0;
        lastAction = 0;
        Serial.println("\n*** TIMEOUT! Credit reset. ***");
        showCredit();
      }
    }
     
    void acceptorPulse()
    {
      lastAction = millis();
      lastPulse = millis();
      pulseCount++;
    }
     
    void acceptorCount()
    {
      digitalWrite(13, digitalRead(13));
    }

all credit goes to Coin acceptor - YouTube

 Coin values:
     1 = 0.5
     2 = 1
     3 = 2
     4 = 10
     */
     
    const byte coinValues[4] = {  5, 10,50, 100};

Isn't there a mismatch between comment and code there?