// Define pin for PIR sensor data pin
const int pirPin = 7;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set PIR sensor pin as input
pinMode(pirPin, INPUT);
}
void loop() {
// Read the value from the PIR sensor
int pirState = digitalRead(pirPin);
// Check if motion is detected
if (pirState == HIGH) {
// Print message to serial monitor
Serial.println("Motion Detected");
}
// Delay before reading again
delay(500);
}