On all Arduino except the DUE, `attachInterrupt` does not use the pin number as first argument but the interrupt number, which is diferent: void attachInterrupt(uint8_t interrupt, void (*ISR)(void), int mode); As documented on [Arduino reference][1], for an Arduino UNO, the mapping is as follows: - interrupt 0 -> pin 2 - interrupt 1 -> pin 3 So just change the code in `setup()` to: attachInterrupt(0, inter, CHANGE); And that should work for pin 2. [1]: http://arduino.cc/en/Reference/AttachInterrupt