- Posts: 1
- Thank you received: 0
boolean checkPir() {
int pir = digitalRead(PirPin);
if (pir == HIGH) {
if (pirState) {
pirState = false;
Serial.println("Motion Detected!");
return true;
delay(50);
}
pirLowTime = true;
}
if (pir == LOW) {
if (pirLowTime) {
pirState = false;
Serial.print("Motion Ended! Delaying for ");
Serial.print(motionDelay/1000);
Serial.println(" seconds.");
pirTime = millis();
pirLowTime = false;
}
if (!pirState && millis() - pirTime > motionDelay) {
pirState = true;
Serial.println("Delay Ended!");
return false;
delay(50);
}
}
}
motion=0.
motion=0.
motion=0.
motion=0.
Motion Detected!
motion=1.
motion=1073670060.
motion=1073670060.
motion=1073670060.
motion=1073670060.
motion=1073670060.
Motion Ended! Delaying for 10 seconds.
motion=0.
motion=681.
motion=1182.
motion=1682.
motion=2183.
motion=2683.
motion=3184.
motion=3685.
motion=4185.
motion=4686.
motion=5186.
motion=5687.
motion=6187.
motion=6688.
motion=7189.
motion=7689.
motion=8189.
motion=8714.
motion=9215.
motion=9715.
Delay Ended!
motion=0.
motion=0.
motion=0.
motion=0.
Please Log in or Create an account to join the conversation.