Night Light Circuit Using An LDR – B1P7
We will now learn how to control an LED, based on the amount of ambient light.
In order to detect light, we will be using something called a photoresistor or light dependent resistor (LDR). As implied by the name, a LDR is a resistor, whose value changes based on the amount of light shining on it.
A snapshot of the datasheet for the LDR present in the kit is shown above and we can see that when light shines on it, the value is roughly around 8-20K Ohms depending on the intensity, while in the absence of light, it has a high value of at least 1M Ohms.
The datasheet also contains a graph that gives you the response curve for different light intensities and this can be used as a reference.
In summary, the LDR converts light into resistance.
- In the presence of light, the resistance between its terminals will be approximately in the 8-20K ohm range.
- In the absence of light, it will have a very high resistance value of about 1M Ohm.
To control an LED electronically, we would need to use a transistor which would need a voltage of at least 0.6-0.7V for it to switch ON. Since the LDR acts as a variable resistor, we can use a voltage divider network to generate a variable output voltage depending on the resistance value.
If we look at the circuit diagram we can see that the LDR and R2 form a voltage divider network whose output is fed into the base of the transistor.
When light shines on the LDR, it will have a value of 10K Ohms. The output voltage would be about 272mV which is not enough to switch ON the transistor.
In the absence of light, the LDR will take a very high value of 1M Ohm. The output voltage would be 2.7V which is more than enough to switch ON the transistor.
We can use the voltage divider formula to determine the resistance value needed for an output voltage of 0.7V – it works up to approx. 30K ohms. We can obviously change the value of R2 or even add a variable resistor depending on the requirement.
Let’s quickly build and test the circuit. Since the LDR is a resistor, it does not have polarity and can be connected either way.
You’ll notice that the LED is OFF due to the ambient light and it switches ON if you block the light shining on the LDR.
This is the basic principle behind sensor based circuits. The sensor changes some circuit parameter which could be resistance, voltage or current and this is used as a trigger. We’re only controlling an LED in this circuit and in the next projects we will learn how to use new components that can be used to build interesting sensor based circuits.
Before we move on, let’s talk about the output of the sensor. The LDR gave us a variable resistance value and we used a voltage divider circuit to give us a corresponding variable voltage. Since the LDR can have different resistance values, the output of the voltage divider circuit can also take multiple values depending on the resistance.
If we plot the output voltage against time, it is easy to see that the output voltage could take any value between 0 and the supply voltage. This type of signal is said to be analog in nature – as it can take multiple different values in a continuous form.
On the other hand, if you had a signal that could only have a finite set of values then it would be a digital signal.
If the signal only has two values, then it would be a binary signal. A binary signal is a type of digital signal.
In the next post, we will use a digital sensor with a binary output to control an LED.