const int pirPin=15;
const int ledPin=12;
bool flag=false;
void setup() {
// put your setup code here, to run once:
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
attachInterrupt(pirPin, PIR_Detect, CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
if (flag) {
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
}
}
void PIR_Detect(){
flag=!flag;
}