How do you use INT2 in Arduino sketches
Has anyone figured out how to do attatchInterrupt for DIG8 (INT2) on Goldilocks yet?
Re: How do you use INT2 in Arduino sketches
Ok. I admit that I'm guessing, but from the Arduino Reference it looks as easy as defining the attached interrupt number 2:
Provided that Arduino codes behaves as expected, then it could work.
---
Except perhaps that, as usual, Arduino team like to complicate simple things.
The 32U4 (Leonardo) they seem to have numbered the Interrupts correctly because it was added later, but they renumbered the earlier 2560 (Mega) and when you think you are using Interrupt 0 you are actually using INT_4.
FFS What were they thinking?
But, anyway that doesn't affect the 1284p because it doesn't have the EICRB register.
Looking at the Arduino WInterrupts.c code in detail, it looks like the attachInterrupt() code could work, but the detachInterrupt() code will not, because they just couldn't be bothered to finish it...
Code: Select all
int pin = 13;
volatile int state = LOW;
void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(2, blink, CHANGE);
}
void loop()
{
digitalWrite(pin, state);
}
void blink()
{
state = !state;
}
---
Except perhaps that, as usual, Arduino team like to complicate simple things.
The 32U4 (Leonardo) they seem to have numbered the Interrupts correctly because it was added later, but they renumbered the earlier 2560 (Mega) and when you think you are using Interrupt 0 you are actually using INT_4.
FFS What were they thinking?
But, anyway that doesn't affect the 1284p because it doesn't have the EICRB register.
Looking at the Arduino WInterrupts.c code in detail, it looks like the attachInterrupt() code could work, but the detachInterrupt() code will not, because they just couldn't be bothered to finish it...