#include <Servo.h>
const byte ledPin = 13;
const byte interruptPin = 2;
const byte servoPin = 3;
volatile bool everythingWorkingFine = true;
Servo myservo;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
myservo.attach(servoPin);
attachInterrupt(digitalPinToInterrupt(interruptPin), somethingBroke, CHANGE);
}
void loop() {
digitalWrite(ledPin, LOW);
myservo.write(180);
delay(500);
myservo.write(90);
delay(500);
if(digitalRead(4)==HIGH)
somethingBroke();
}
void somethingBroke() {
while(true)
{
digitalWrite(ledPin, HIGH);
}
}