Interrupt differences

Hi guys,
Where's the thing, i'm using this code:

const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
volatile int buttonState = 0; // variable for reading the pushbutton status
int counter;
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
// Attach an interrupt to the ISR vector
attachInterrupt(digitalPinToInterrupt(buttonPin), pin_ISR, CHANGE);


void loop() {
// Nothing here!

void pin_ISR() {
buttonState = digitalRead(buttonPin);
digitalWrite(ledPin, buttonState);


In Arduino Uno it works perfectly. In Arduino Due it stops after several serial prints on the serial monitor. Can any one tell me why, and how to solve this?

You're lucky it works at all on ANY Arduino. You CANNOT use Serial.print in an ISR. It WILL eventually fail.

Ray L.

Furthermore, if your button is not "debounced", it will create havoc with an interrupt.