const int pirPin = 2; // PIR sensor pin (PB2)
const int ledPin = 0; // LED pin (PB0)
void setup() {
pinMode(pirPin, INPUT); // set PIR sensor pin as input
pinMode(ledPin, OUTPUT); // set LED pin as output
}
void loop() {
if (digitalRead(pirPin) == HIGH) { // check if motion is detected
digitalWrite(ledPin, HIGH); // turn on LED
delay(1000); // keep LED on for 1 second
} else {
digitalWrite(ledPin, LOW); // turn off LED
}
delay(100); // small delay to debounce the sensor
}
Eng Odeh Alamrow