void setup() {
// put your setup code here, to run once:
int pirPin = 2; // PIR sensor output pin
int ledPin = 13; // LED pin
}
void loop() {
// put pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int pirState = digitalRead(pirPin); // Read the PIR sensor
if (pirState == HIGH) { // If motion is detected
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("Motion detected: LED ON");
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
Serial.println("No motion: LED OFF");
}your main code here, to run repeatedly:
}