const int pirPin = 2; // the pin the PIR sensor is connected to const int ledPin = 9; // the pin the LED is connected to void setup() { pinMode(pirPin, INPUT); // set the pin with the PIR sensor as an input pinMode(ledPin, OUTPUT); // set the pin with the LED as an output } void loop() { // read the state of the PIR sensor int pirState = digitalRead(pirPin); // check if the PIR sensor is detecting motion if (pirState == HIGH) { // turn the LED on digitalWrite(ledPin, HIGH); } else { // turn the LED off digitalWrite(ledPin, LOW); } }