// GLOBALS & CONSTANTS
int LED_PIN = 3;
int BTN_PIN = 7;
volatile int btn_val = 1;
void setup() {
pinMode(LED_PIN, OUTPUT);
// INPUT_PULLUP necessary for the button, since there’s no external resistor
pinMode(BTN_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BTN_PIN), toggleLED, FALLING);
}
void loop() {
}
void toggleLED() {
btn_val ^= 1;
digitalWrite(LED_PIN, btn_val);
}