int pirPin = 3; // Digital pin connected to the PIR sensor output
int ledPin = 5; // Digital pin connected to the LED
void setup() {
pinMode(pirPin, INPUT); // Set the PIR sensor pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
}
void loop() {
int pirState = digitalRead(pirPin); // Read the PIR sensor output
if (pirState == HIGH) {
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
This is the code. like share subscribe
Thank you