Arduino UNO R3 and Digital interrupt pin issue

Hi,

Is the P2 and P3 are the two Arduino UNO R3 Digital interrupt pin? Is there any config or lib to add to code? I try to connect an coin accpetor to Arduino but doesn't work, i think Digital interrupt pin are the problem

Thanks

dias1973: Is the P2 and P3 are the two Arduino UNO R3 Digital interrupt pin? Is there any config or lib to add to code?

All explained here.

I try to connect an coin accpetor to Arduino but doesn't work, i think Digital interrupt pin are the problem

Why do you think that?- but of course we can't see your code from here to comment.

Hi thanks

I tested it with many codes, even with this code you can find on Arduino forum

    /*
      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(9600);
     
      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));
    }

Shall I connect 2 and 3?

Arduino can't detect coins, when I put the 1 and 2 pins I get successive weired data