Interrupts don't work
On all Arduino boards except the DUE, attachInterrupt() does not use the pin number as first argument but the interrupt number, which is different:

void attachInterrupt(uint8_t interrupt, void (*ISR)(void), int mode);


As documented on Arduino reference, 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.