Reassigning interrupts to different pins
I have a Teensy 3.2 project where I am using a APDS9960 gesture sensor that requires an interrupt. Works great with the default interrupt of 2.
I am trying to re-assign the default interrupt 2 to another pin because I want to use pin 2 for something else (to keep some buttons/sensors in numerical order). Would like to assign pin 0 as the interrupt pin instead.
I've been over the Arduino interrupt reference, and tried a number of things, but can't seem to make this simple change (if indeed it is simple).
// SparkFun_APDS9960 variables
byte interruptPin = 0;
#define APDS9960_INT interruptPin // Interrupt
// Set gesture interrupt pin as input
pinMode(APDS9960_INT, INPUT_PULLUP);
In setup I am using:
attachInterrupt(interruptPin, interruptRoutine, FALLING);
I also tried:
attachInterrupt(digitalPinToInterrupt(0), interruptRoutine, FALLING); //
https://forum.pjrc.com/threads/32286-APDS-9960-with-teensy
Neither is working.
I've tried the following:
pinMode(0, INPUT);
digitalWrite(0,HIGH);
My ISR code:
if( isr_flag == 1 ) {
detachInterrupt(interruptPin);
handleGesture();
isr_flag = 0;
attachInterrupt(interruptPin, interruptRoutine, FALLING);
}
Any thoughts?