I am working on code to ON the LED for 10 seconds after certain condition (x=false), but the code below runs infinitely. How should correct it? Thanks. I don't want to use delay() function as it stop the other functions running inside the loop.
Jack9938:
I am working on code to ON the LED for 10 seconds after certain condition (x=false), but the code below runs infinitely. How should correct it? Thanks. I don't want to use delay() function as it stop the other functions running inside the loop.
You're setting TimerLighting = millis() each time through loop() and then immediately checking if(millis()-TimerLighting <=10000). This will always be true! Just as looking at a clock every 5 minutes to see if an hour has passed since you last looked at the clock will always be false. TimerLighting = millis(); should be in setup() so that it only gets set once.