#define pinPIR 2
#define pinRelay 3
void setup() {
pinMode(pinPIR, INPUT);
pinMode(pinRelay, OUTPUT);
Serial.begin(9600);
}
void loop() {
int nilaiSwitch = digitalRead((pinPIR));
if(nilaiSwitch == 1){
digitalWrite(pinRelay, HIGH);
Serial.println("ada pergerakan");
}
else{
digitalWrite(pinRelay, LOW);
Serial.println("tidak ada pergerakan");
}
}