How to Use a Light Dependent Resistor (LDR)
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.

Step 1: How it Works

How to Use a Light Dependent Resistor (LDR)
How to Use a Light Dependent Resistor (LDR)
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

See what it looks like on a Breadboard.

Step 2: The Code

You can use the AnalogInOutSerial code (File -> Examples -> Analog -> AnalogInOutSerial) to measure a value on A0 and print it to the Serial Monitor.

Step 3: How to Make it Better

  • The AnalogInOutSerial code also uses the measured sensor value to change the brightness of an LED on pin 9. Add the LED.
  • Make an Arduino Light Sensitive Bar Graph.
  • Graph the light readings on your PC. See How to Send Data from Arduino to a PC

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel