I have a nano 2040 connect and trying to get the external interupts to work. My first attempt in VSC generated an error error: 'led_ISR' was not declared in this scope for the line attachInterrupt(digitalPinToInterrupt(button), led_ISR, CHANGE); with led_ISR being underlined.
Then using the Arduino IDE and MBED core the code generates no errors but does nothing, the code is below. I have tried replacing button for 16 in the ISR setup, CHANGE for LEVEL but nothing works.
Does any one know if external pin ISR's are implemented for the 2040 connect?
For VSC, this used to have MBED as an option but now only shows the Arduino platform, so I am assuming this is the issue in VSC.
If I rem out the attachInterrupt line, and then setting the int led_state HIGH or LOW, the state of the led chnages and works OK.
I have also tried Earle Philhower board and this makes no difference.
#define led 14 // led as pin 14
#define button 16 // input for IRQ in pin 16
int led_state = LOW; // high / low state of led
void setup() {
pinMode(led, OUTPUT); // Led as output on pin 14
pinMode(button, INPUT_PULLUP); // input on pin 16, pulled high
attachInterrupt(digitalPinToInterrupt(button), led_ISR, CHANGE);
}
void led_ISR(){
led_state = !led_state;
}
void loop(){
digitalWrite(led, led_state);
}