const int LED_PIN = 13;
const int INTERRUPT_PIN = 2;
volatile bool ledState = LOW;
double i;
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), myISR, FALLING);
// trigger when button pressed, but not when released.
Serial.println("start");
}
void loop() {
digitalWrite(LED_PIN, ledState);
i=i+1;
//Serial.println(i);
//Serial.println(ledState);
delay(10);
if (i==1000) i=0;
}
void myISR() {
ledState = !ledState;
// note:
// LOW == false == 0,
// HIGH == true == 1,
// so inverting the boolean is the same as switching between LOW and HIGH.
Serial.print("x");
}