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);
Serial.begin(115200);
}
void loop() {
// Nothing here!
}
void pin_ISR() {
buttonState = digitalRead(buttonPin);
digitalWrite(ledPin, buttonState);
Serial.println(buttonState);
counter++;
Serial.println(counter);
}
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?
Thanks.