- Thu Jun 06, 2013 3:34 pm
#160244
Hey all,
I'm working with a Sparkfun ProMicro 5V 16 MHz. I have an IR sensor that outputs high or low, depending on the color of the paper it's in front of. The problem is that I can get it to trigger an interrupt on pins 2 or 3 (int.0 or int.1), but using the same setup and program, I can't get interrupt 2, 3, or 4 to work. According to the AttachInterrupts page (http://arduino.cc/en/Reference/attachInterrupt) the Leonardo and ProMicro should support interrupts on pins 0, 1, and 7 as well. Am I missing something? My program is as follows, I tested the sensor with int.0 and int.1 and it works fine. When I changed the interrupt to int.2, 3, or 4, I get nothing.
I'm working with a Sparkfun ProMicro 5V 16 MHz. I have an IR sensor that outputs high or low, depending on the color of the paper it's in front of. The problem is that I can get it to trigger an interrupt on pins 2 or 3 (int.0 or int.1), but using the same setup and program, I can't get interrupt 2, 3, or 4 to work. According to the AttachInterrupts page (http://arduino.cc/en/Reference/attachInterrupt) the Leonardo and ProMicro should support interrupts on pins 0, 1, and 7 as well. Am I missing something? My program is as follows, I tested the sensor with int.0 and int.1 and it works fine. When I changed the interrupt to int.2, 3, or 4, I get nothing.
Code: Select all
int flag = 0;
void setup() {
attachInterrupt(0, test, CHANGE);
}
void test(){
if (flag == 0){
flag = 1;
}
else {
flag = 0;
}
}
void loop() {
if (flag == 1){
digitalWrite(17, HIGH);
}
else {
digitalWrite(17, LOW);
}
}