Lots of projects use a Light Dependent Resistor (LDR) to sense light levels but don't really focus on how they work.

This project shows you how to use a Light Dependent Resistor (LDR) to sense light levels, measure those levels with the Arduino and print the measurements to the Serial port.

Arduino measures Voltages on pins A0 to A5; but the LDR is a variable resistor (varying with Light). So we need to convert the varying resistance to a voltage that the Arduino can measure.

We do that by using the LDR and a Resistor in a Potential Divider circuit.


By the way. If you like this Instructable, you might also like:


Step 1: How it Works

The top of the Potential Divider is 5V; the bottom is at 0V and the middle (connected to A0) is some value between 5V and 0V that varies as the LDR resistance varies. Remember the LDR resistance varies with Light so the Voltage at A0 will too.

If you want to be very precise and technical then you can work out the Voltage on A0 as :

Va0 = 5 * R1/(R1+R2)

where Va0 is the voltage at A0 pin, R2 is the top resistor value, R1 is the bottom resistor value;

e.g. R1 = 10k, R2 = 5k => Va0 = 5 * 10000/(10000 + 5000) = 5 * 10/15 = 3.33V

The LDR has a high value when no light is present. The value of resistance of the LDR depends on the type. In this case it's about 10k. As the light level increases the resistance drops, which makes the current increase (by Ohm's Law), which in turn, makes the voltage at A0 (Va0) increase.

Electrically this is what's happening (skip this if you're not interested in this): The LDR and resistor are in series with the applied voltage (5V), so the current flowing through them is the same (the A0 pin draws virtually zero current). So the current through the resistor is (by Ohm's Law):

I = 5 / (R1+R2)

Now, the voltage across the resistor is applied to A0. Again, by Ohm's Law that is:

Va0 = I * R1

Substituting the equation for I back in to this equation we get:

Va0 = 5 * R1/(R1+R2)

See what it looks like on a Breadboard.

<p>hy.plz tell me how to shield LDR from stray light.i am working on burglar alarm using LDR and lazer...i want to make ldr operative just with lazer light.plz plz reply me soon</p>
<p>Put the LDR in a tube. The tube will shield the LDR from stray light so only the laser light will fall on it. SImple as that :-)</p>
<p>hey how do you use an ldr to create a robot that can follow light</p>
<p>You would need 2 LDRs separated by about 5 to10cm. Program the robot to turn in the direction of the greatest amount of light (i.e. left LDR or right LDR)</p>
<p>hy.plz tell me how to shield LDR from stray light.i am working on burglar alarm using LDR and lazer...i want to make ldr operative just with lazer light.plz plz reply me soon</p>
<p>Made it, will check ur other projects!</p>
<p>THIS VIDEO IS FOR BEGINNER https://www.youtube.com/watch?v=S-QddCWt5l4</p>
<p>Hello,</p><p>Why do you need to connect a resistor to the LDR? Can you connect it directly between +5v and A0 without the resistors?</p>
<p>Hi tanmay, you need the resistor in order to create a so-called voltage divider. Basically you are turning the varying resistance of the LDR into a varying voltage at the midpoint (between the LDR and the resistor). This can then be easily measured by any ADC (Analog to digital converter). </p><p>If you don't put a resistor to ground and connect it directly between +5V and A0 then the ADC will not measure anything that is related to the LDR's resistance. All that's happening is a varying current enters the A0 pin which can not be measured like this. ADCs can only measure voltages directly.</p>
<p>someone have an idea using ldr measure the angle of sun, display in 7 segment </p>
<p>it's not that easy. ldr only measure the power of light , not the angle to sun.</p>
<p>Great article .. and got it working with my board</p>
<p>What resistance should i use for the resistor, or can i use any?</p>
<p>aap sab logo nai yai to bata dia yeh bhi bato do kaha par milta hai please</p>
<p>If you reside in Delhi, then go to Chandani Chowk -&gt;Lajpat Rai Market -&gt; Shop 595 -&gt;Bonus Electronics, there are many electronics shops over there, i prefer this one.</p>
<p>find it on electronics shop... its easy to find ,, ask for LDR</p>
<p>Usage of LDR with your Arduino board is very well explained in simple words here &quot;http://newchip.in/blog/arduino-analog-port-reading-ldr-tutorial/&quot; i personally recommend this website</p>
perhaps it would be better suited to write one to show us how. I, for one, thought this was a pretty good ible.

About This Instructable




More by akellyirl:Smart Home Thermostat Arduino Yun Messager Arduino Esplora Flight Simulator 
Add instructable to: