const int pirPin = 2;
void setup() {
Serial.begin(9600);
pinMode(pirPin, INPUT);
Serial.println("PIR Sensor warming up...");
delay(30000); // wait 30s for sensor to stabilize
Serial.println("Ready to detect motion!");
}
void loop() {
int pirValue = digitalRead(pirPin);
if (pirValue == HIGH) {
Serial.println("Motion detected!");
} else {
Serial.println("No motion");
}
delay(500);
}