void setup() {
pinMode(4,INPUT_PULLUP); // PIR sensor as input
pinMode(12, OUTPUT);
Serial.begin(115200);
}
void loop() {
int a=digitalRead(4);
if (a==1)
{
digitalWrite(12, HIGH);
Serial.println("Motion detected");
}
else
{
digitalWrite(12, LOW);
Serial.println("Not detected");
}
delay(2000);
}