attachInterrupt() example sketch won't compile

I am trying to learn how to use external interrupts on an Arduino Uno. the Arduino Reference page for attachInterrupt() lists the following example code:

const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}

void loop() {
  digitalWrite(ledPin, state);
}

void blink() {
  state = !state;
}

I copied this code into a blank sketch I called test_interrupt, and got the following error message when I checked the sketch:

Arduino: 1.0.6 (Windows XP), Board: "Arduino Uno"
C:\Program Files\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Program Files\Arduino\hardware\arduino\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\variants\standard C:\DOCUME~1\User\LOCALS~1\Temp\build4157219780155555346.tmp\test_interrupt.cpp -o C:\DOCUME~1\User\LOCALS~1\Temp\build4157219780155555346.tmp\test_interrupt.cpp.o 

test_interrupt.ino: In function 'void setup()':
test_interrupt:8: error: 'NOT_AN_INTERRUPT' was not declared in this scope

Any help would be greatly appreciated...

1.0.6 is a VERY old version of the IDE. I suggest updating it :wink:

septillion:
1.0.6 is a VERY old version of the IDE. I suggest updating it :wink:

I agree. I don't think the digitalPinToInterrupt() concept existed way back then.

...R

Robin2:
I don't think the digitalPinToInterrupt() concept existed way back then.

It did:

[nobbc]
    ARDUINO 1.0.6 - 2014.09.16
    ...
    [core]
    ...
    * Backported digitalPinToInterrupt macro from IDE 1.5.x
[/nobbc]

-- except this part:

[nobbc]
    ARDUINO 1.0.7   (never released)
    ...
    [core]
    * Fixed missing NOT_AN_INTERRUPT constant in digitalPinToInterrupt() macro
[/nobbc]

oqibidipo:
It did:

For some new meaning of the word "backported" :slight_smile:

...R