int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop() {
if (digitalRead(inputPin) == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
Serial.println("Motion detected!");
delay(5000);
digitalWrite(ledPin, LOW);
}
else {
Serial.println("No Motion");
}
}