WOOSH! The word hysteresis just flew over my head. I wiki'ed it but still don't get it. Even the wiki WOOSHed over my head.
Can you explain what that is like I am FIVE YEARS OLD?
Hysteresis is simply that the system doesn't react in exactly the same way going in two different directions. This can be used to stop the system from "dithering" at the switch-over point.
To take an easy example that I am doing at the moment, I am building a '168 controlled greenhouse heater. It measures the temperature and if it gets too low it switches on a heater. Once it's warm enough, the heater goes off.
If I switch on at below (say) 5'C and off at above 5'C then if the temperature hovers around 5'c then I may switch on and off repeatedly and burn out the relay. I therefore built in two safety features:
1 - I sample for 2 minutes and average before making a decision.
2 - I switch on at below 5'C and off again at above 6'C.
Number 2 is the "hysteresis" - it behaves differently depending upon whether the temperature is rising or falling. When the temp is falling it has to reach below 5'C to trigger the switch (on) when it is rising I have to reach 6'C for an off-event.
There will be more noise and general over-sensitiveness on your LDR so you could easily get a load of nonsense switching around the threshold point. As a result you can either:
Have a different level for switch-on in comparison with switch-off, so that once on, the level has to rise a measurable amount before it will switch off again; or
Average (or simply wait to sample) for a while before making a decision. Then you have time for the overall trend to lighter or darker to overtake the noise and also even if you do switch on and off again a few times it won't be flickering like a dying strip-light for 20 minutes each morning and evening. Of course you can do both, as I did above.
Hope that makes some sense.