The interrupt mapping in the pin_arduino.h file is the following code line:
#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT)))
As I understand this line of code:
if p==2 → INT0
else if p==3 → INT1
else if 18<=p<=21 → INT(23-p)
else NOT_AN_INTERRUPT
If this is correct, the pins are mapped as follows:
pin2 to INT0,
pin3 to INT1,
pin18 to INT5,
pin19 to INT4,
pin20 to INT3,
pin21 to INT2.
This mapping matches “http://arduino.cc/en/Reference/attachInterrupt”, but pretty much no-where else (including the ATMEGA2560 datasheet).
This will only come up if you use interrupt pins 2 to 5.
Has anyone else come across this proble