@ HKJ-lygte , change the logic around. Do the comparison with subtraction, that way the millis() roll over has no effect. Now it has.
const byte InputPin = 3;
const byte LedPin = 13;
unsigned long timer;
void setup() {
//Serial.begin(9600);
pinMode(LedPin, OUTPUT);
pinMode(InputPin, INPUT);
}
void loop() {
// When PIR active, store millis()
if (digitalRead(InputPin)){
timer = millis();
}
// When millis() has not advanced more then 300ms from timer
digitalWrite(ledPin, millis() - timer < 300);
}
PS 300ms is afwfully short.
@Umair_Khalid_Khan In what mode is the PIR? Retriggerable or Non-retriggerable?