The 555 can be used with a light dependent resistor (LDR) to form a light-sensitive switch for switching on a light at sun set and off at sun rise. A light sensitive switch may also be used in an intruder alarm system to trigger the alarm when an intruder interrupts any light source.
The value of the R1 resistor must be adjusted carefully so that under normal conditions when the light falls on the LDR, the voltage across the LDR is less than Vcc/3 and the output of the 555 is high. The actual value of R1 depends on the resistance of the LDR. As the light fades or the light on the LDR is interrupted (maybe by an intruder) the voltage across the LDR rises above 2Vcc/3 and changes the logic level of the IC output. The output goes low and actuates the relay. When the light intensity is restored, the voltage across the LDR falls back below Vcc/3 causing the output to go back to its high level and to de-energize the relay.
There is a voltage difference of Vcc/3 between turning on and turning off voltages. This voltage difference causes some hysteresis which prevents relay chatter. The hysteresis is very useful because increases stability (prevents oscillations) but it reduces sensitivity. So, we use R2 to reduce hysteresis in order to improve sensitivity. The value of R2 must be of about one and a half times of the LDR resistance in its illuminated condition.
The relay should be of a DC type with a coil operating at about Vcc and not drawing more than 200mA. A relay is an inductive load and when its current is interrupted, the collapsed magnetic field (due to its coil) generates a high reverse emf (transient voltage) that can damage the 555. The solution to this problem is the connection of diode D1 across the relay coil so that it conducts and absorbs the transient. D1 is connected in such polarity so it remains reverse biased in normal operation.