//Define Pins
int pir_1_Pin = 8;
int pir_2_Pin = 7;
int pir_3_Pin = 6;
int pir_4_Pin = 5;
int relayPin = 10;
//Relay output run time
unsigned long relay_run_time = 6000;
void setup() {
// put your setup code here, to run once:
//Setup PIR Input Pins
pinMode(pir_1_Pin, INPUT);
pinMode(pir_2_Pin, INPUT);
pinMode(pir_3_Pin, INPUT);
pinMode(pir_4_Pin, INPUT);
//Setup Relay Output Pin
pinMode(relayPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int motion_1_input = digitalRead(pir_1_Pin);
int motion_2_input = digitalRead(pir_2_Pin);
int motion_3_input = digitalRead(pir_3_Pin);
int motion_4_input = digitalRead(pir_4_Pin);
if (motion_1_input == HIGH || motion_2_input == HIGH || motion_3_input == HIGH || motion_4_input == HIGH) {
unsigned long relay_start_time = millis();
while ((millis()- relay_start_time) < relay_run_time) {
digitalWrite(relayPin, HIGH);
}
} else {digitalWrite(relayPin, LOW);}
}