// Define the digital pins for the PIR sensor and LED
int pirPin = 2;
int ledPin = 7;
void setup() {
// Set the PIR sensor pin as input
pinMode(pirPin, INPUT);
// Set the LED pin as output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the value from the PIR sensor
int pirValue = digitalRead(pirPin);
// If the PIR sensor detects motion, turn on the LED
if (pirValue == HIGH) {
digitalWrite(ledPin, HIGH);
}
// If the PIR sensor does not detect motion, turn off the LED
else {
digitalWrite(ledPin, LOW);
}
}