// Maria Clapp 16/01/23
const int buttonPin = 2;
const int ledPin =13;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
attachInterrupt(digitalPinToInterrupt(buttonPin), toggleLED, CHANGE); // attach interrupt to button pin, call toggleLED function on CHANGE
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("this is the main program execution");
delay(500);
}
void toggleLED(){
if(digitalRead(buttonPin) == HIGH){
digitalWrite(ledPin, HIGH); // tunr oon LED
Serial.print("Interrup event, led turn on");
}
else {
digitalWrite(ledPin, LOW);
}
}