// #define p_switch 2
#define p_relay 3
#define inPIN 4
int pirState = LOW;
void setup() {
// put your setup code here, to run once:
// pinMode(p_switch, INPUT_PULLUP);
pinMode(p_relay, OUTPUT);
pinMode(inPIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// int nilaiSW = digitalRead(p_switch);
// if(nilaiSW == 0){
// digitalWrite(p_relay, HIGH);
// }
// else{
// digitalWrite(p_relay, LOW);
// }
int nswitch = digitalRead(inPIN);
if (nswitch == 1){
digitalWrite(p_relay, HIGH);
Serial.println("CING TINGALI SAHA ETA!");
pirState = HIGH;
}
else {
digitalWrite(p_relay, LOW);
if (pirState == HIGH){
Serial.println("TOS LAH AMAN!");
pirState = LOW;
}
}
}