int X;
void setup() {
pinMode(2, OUTPUT); // Set the LED as an output
pinMode(3, INPUT); // Set the PIR motion sensor as an input
}
void loop() {
X = digitalRead(3); // Read the sensor value
if (X == HIGH){ // If motion detected or button pressed
digitalWrite(2, HIGH); // Turn the LED on
}
else {
digitalWrite(2, LOW); // Turn the LED off
}
//delay(500); // Delay for 500 milliseconds
}