//Board : Arduino Uno
//Design : dunia_budi
//Test Report : Ok-November 23-10
int pirPin1 = 2; // Pin sensor gerak
int relayPin1 = 7; // Pin relay
int pirPin2 = 3; // Pin sensor gerak
int relayPin2 = 8; // Pin relay
int pirPin3 = 4; // Pin sensor gerak
int relayPin3 = 9; // Pin relay
int pirPin4 = 5; // Pin sensor gerak
int relayPin4 = 10; // Pin relay
int relayState = LOW;
void setup() {
pinMode(pirPin1, INPUT);
pinMode(relayPin1, OUTPUT);
pinMode(pirPin2, INPUT);
pinMode(relayPin2, OUTPUT);
pinMode(pirPin3, INPUT);
pinMode(relayPin3, OUTPUT);
pinMode(pirPin4, INPUT);
pinMode(relayPin4, OUTPUT);
Serial.begin(9600);
}
void loop() {
int motionState1 = digitalRead(pirPin1);
int motionState2 = digitalRead(pirPin2);
int motionState3 = digitalRead(pirPin3);
int motionState4 = digitalRead(pirPin4);
if (motionState1 == HIGH)
{
Serial.println("Gerakan terdeteksi pada Sensor 1!");
digitalWrite(relayPin1, HIGH);
delay(5000);
digitalWrite(relayPin1, LOW);
}
if (motionState2 == HIGH) {
Serial.println("Gerakan terdeteksi pada Sensor 2!");
digitalWrite(relayPin2, HIGH);
delay(5000);
digitalWrite(relayPin2, LOW);
}
if (motionState3 == HIGH) {
Serial.println("Gerakan terdeteksi pada Sensor 3!");
digitalWrite(relayPin3, HIGH);
delay(5000);
digitalWrite(relayPin3, LOW);
}
if (motionState4 == HIGH) {
Serial.println("Gerakan terdeteksi pada Sensor 4!");
digitalWrite(relayPin4, HIGH);
delay(5000);
digitalWrite(relayPin4, LOW);
}
}