This controller turns on the outside lights as soon as it becomes dark and then turns the lighting off at a set time, so that the lights are not burning needlessly all night long. It is also possible to automatically turn the lights on again in the morning at another preset time. Then once it is light enough outside they turn off again. You could obtain this functionality with an LDR and a switching time clock. The LDR senses when it is dark enough and the clock can turn the lights off again at a preset time, and the other way around. To keep the design simple and cheap, a different solution was chosen for this switching clock. A normal clock needs to be seinitially and perhaps again periodically as the clock drifts after a while. In addition, a display is required to set this clock, plus a few push buttons. Here a different approach is taken. Starting with the fact that an LDR can detect the sunrise and sunset and that the sun ‘loops’ around in 24 hours, we can use this knowledge as an alternative method for determining the time.
This clock does not need to be set. The solar clock is born. The controller is built around a PIC16F628A, which runs from its internal RC oscillator at 4 MHz. When sunrise is detected, a counter is started, this counter keeps running until the following sunrise (reset). At sunset, the current value of the counteris stored in the variable ‘zontot’. So after sunset the time can be determined with the formula:
time = counter – zontot/2
This design has two pushbuttons to set the switching times; ‘Evening off’ (S1) and ‘Morning on’ (S2). The push buttons can only be operated after sunset and before sunrise. If in the evening (after sunset, the garden light are on) button S1 is pushed, the lights will from now on go off at this particular time. When button S2 is pressed in the morning before sunrise, the lights, from now on, will turn on at this time and continue to be on until sunrise.