/**
  Arduino INT0 example. Press the button to toggle the LED.

  Copyright (C) 2021, Uri Shaked. Released under the MIT License.
*/

#define BTN_PIN 2

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(BTN_PIN, INPUT_PULLUP);

  // Enable INT0 (on pin 2)
  cli();
  EICRA |= bit(ISC01); // Toggle the interrupt on pin's falling edge
  EIMSK |= bit(INT0);  // Enable it
  sei();
}

void loop() {
}

ISR(INT0_vect) {
  PINB = bit(PB5); // Toggle the LED, PB5 = pin13
  // you could also use the Arduino API:
  // digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}