const int pirPin = 2; // Digital pin connected to the OUT pin of the PIR sensor
void setup() {
Serial.begin(9600); // Initialize serial communication for debugging
pinMode(pirPin, INPUT); // Set the PIR pin as input
}
void loop() {
int motion = digitalRead(pirPin); // Read the state of the PIR sensor
if (motion == HIGH) {
Serial.println("Motion detected!");
} else {
Serial.println("No motion detected.");
}
delay(1000); // Adjust delay as needed
}