#include <Arduino.h>
// Define the pin number for PIR sensor input
#define PIR_PIN 5
void setup() {
// Initialize serial communication at 9600 baud
Serial.begin(9600);
// Set the PIR pin as input
pinMode(PIR_PIN, INPUT);
}
void loop() {
// Read the state of the PIR sensor
int pirState = digitalRead(PIR_PIN);
// Check if motion is detected
if (pirState == HIGH) {
Serial.println("Motion detected!");
} else {
Serial.println("No motion detected.");
}
// Delay for a short period
delay(500);
}