Add more pins with interrupt (for Motor Encoder)

Hi, I am following this tutorial.
http://www.instructables.com/id/Motor-With-Encoder-How-to-Read-Input-Value-From-En/

And it is working well. But now I want to attach another motor. I need the Encoder to at an Interrupt Pin. How do I add more? There is only two on the Uno and I already using the SCL/SDA for the motor (same as 2 and 3). I tried this, but it doesn't work. The encoder does count up, but very slowly.

https://playground.arduino.cc/Main/PinChangeInterrupt

/* Encoder Library - Basic Example
 * http://www.pjrc.com/teensy/td_libs_Encoder.html
 *
 * This example code is in the public domain.
 */

#include <Encoder.h>

// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder myEncLeft(3,2);
Encoder myEncRight(7,8);
//   avoid using pins with LEDs attached
long oldPosition  = -999;

void pciSetup(byte pin)
{
    *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
    PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
    PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group
}
 
// Use one Routine to handle each group
 
ISR (PCINT0_vect) // handle pin change interrupt for D8 to D13 here
 {    
     digitalWrite(13,digitalRead(8) and digitalRead(9));
 }
 
ISR (PCINT1_vect) // handle pin change interrupt for A0 to A5 here
 {
     digitalWrite(13,digitalRead(A0));
 }  
 
ISR (PCINT2_vect) // handle pin change interrupt for D0 to D7 here
 {
     digitalWrite(13,digitalRead(7));
 }  

void setup() {
  int i;
 
// set pullups, if necessary
  for (i=0; i<=12; i++)
      digitalWrite(i,HIGH);  // pinMode( ,INPUT) is default
 
  for (i=A0; i<=A5; i++)
      digitalWrite(i,HIGH);
 
  pinMode(13,OUTPUT);  // LED
 
// enable interrupt for pin...
  pciSetup(7);
  pciSetup(8);
  pciSetup(9);
  pciSetup(A0);
  
  Serial.begin(9600);
  Serial.println("Basic Encoder Test:");
}

void loop() {
  long masterPower = myEncLeft.read();
  if (masterPower != oldPosition) {
    oldPosition = masterPower;
    Serial.print("L: ");
    Serial.println(masterPower);
    delay(500);
  }
  
  long slavePower = myEncRight.read();
  if (slavePower != oldPosition) {
    oldPosition = slavePower;
    Serial.print("R: ");
    Serial.println(slavePower);
    delay(500);
  }

}

There is only two on the Uno and I already using the SCL/SDA for the motor (same as 2 and 3)

The external interrupt pins are 2 and 3. They are NOT SCL/SDA.

For two encoders, on 2 external interrupt pins each, you'll need a different Arduino. The Mega has 5 external interrupt pins.

Or.

Do a little research and play your encoders without using interrupts.

As much fun and utility they can be, interrupts can be tricky and very often can be programmed without. I invented my own encoder, then I discovered almost exactly the same thing in a nice library.

They basic trick is to give your encoders some regular attention by calling a service routine from your main loop.

can do either. Other advantages accrue as he points out. I had some crummy rotary encoders that def benefited from the denouncing.

Save interrupts for when you just can't not.

a7

PaulS:
The external interrupt pins are 2 and 3. They are NOT SCL/SDA.

For two encoders, on 2 external interrupt pins each, you'll need a different Arduino. The Mega has 5 external interrupt pins.

Oh, I got them confused with the Leonardo, you are right.

benefited from the denouncing.

Got to love auto-correct.

For human operated encoders an interrupt is pretty overkill. For motors it can be useful. You can switch to pin change interrupts BUT this is a single interrupt for multiple pins. So inside the interrupt you have to check what changed. Not to hard though.