#define pinPIR 2
#define pinRelay 3
void setup() {
// put your setup code here, to run once:
pinMode(pinPIR, INPUT);
pinMode(pinRelay, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int nilaiPIR = digitalRead(pinPIR);
if (nilaiPIR == 1){
digitalWrite(pinRelay, HIGH);
Serial.print("Ada Gerakan : ");
Serial.println(nilaiPIR);
} else {
digitalWrite(pinRelay, LOW);
Serial.println("Tidak ada gerakan");
}
delay(100);
}