const int motionPin1 = 11; // PIR Motion Sensor 1 (Front)
const int motionPin2 = 12; // PIR Motion Sensor 2 (Left)
const int motionPin3 = 13; // PIR Motion Sensor 3 (Right)
const int relayPin = 8; // Relay control pin
const int ledPin = 9; // LED indicator pin
unsigned long activationTime = 0;
const unsigned long activationDuration = 60000; // milliseconds
const unsigned long offDelay = 60000; // milliseconds
void setup() {
pinMode(motionPin1, INPUT);
pinMode(motionPin2, INPUT);
pinMode(motionPin3, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(relayPin, LOW);
digitalWrite(ledPin, LOW);
}
void loop() {
if (digitalRead(motionPin1) == HIGH || digitalRead(motionPin2) == HIGH || digitalRead(motionPin3) == HIGH) {
if (millis() - activationTime <= activationDuration) {
digitalWrite(relayPin, HIGH); // Activate the relay
digitalWrite(ledPin, HIGH); // Turn on the LED
activationTime = millis(); // Record the activation time
}
} else {
if (millis() - activationTime >= activationDuration + offDelay) {
digitalWrite(relayPin, LOW); // Deactivate the relay
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
}