int ledPin = 13; // LED on Pin 13 of Arduino int pirPin = 7; // Input for HC-S501 int pirValue; // Place to store read PIR Value void setup() { pinMode(ledPin, OUTPUT); pinMode(pirPin, INPUT); digitalWrite(ledPin, LOW); } void loop() { pirValue = digitalRead(pirPin); if (pirValue == HIGH) { // check if the sensor is HIGH digitalWrite(ledPin, HIGH); // turn LED ON Serial.println("Motion detected!"); delay(1000); // delay 100 milliseconds } else { digitalWrite(ledPin, LOW); // turn LED OFF Serial.println("Motion stopped!"); delay(1000); // delay 100 milliseconds } }