Scenario: I am setting up a night-time home lighting curcuit using Arduino using several PIR sensors, and relays to control hidden LED strip lights etc. Now, I only want the entire circuit to become operational when the ambient light level has fallen below a certain threshold. However, the value of the analog reading might fluctuate slightly around a value for a few mins as the ambient light decreases i.e. the value might be something like 100, 99, 99, 98, 99, 98, 98,97 etc... so falling over time yes, but it might rise by a value too.
So, I want to be able to write some code that will check that the analoge reading is below a certain threshold AND has been for several minutes - before I then proceed with the rest of the code.
A WHILE statement would do it, but how do I code the expression? How do I check that a value on say, A0, is dropping AND has been at value 'v' or less, for 't' time please?
Just can't get my head around it!