How to Hookup Light Dependent PhotoResistor (LDR) to an Arduino

The LDR (Light Dependent Resistor) is also known as a Photo resistor. It is a simple device that has the characteristic of changing its resistance based on the amount of light that hits it. Its resistance will be lower when a light is shone on it. When the light is removed the resistance will be at it's highest.

The LDR could be used to detect day or night to control some device. If you wanted to know if the light goes out when the fridge door closes then the LDR with an Arduino could be used to answer that question. The LDR will not give you an accurate reading to the amount of light but it will enable you to detect a transition between the amount of light that is available.


Light Dependent PhotoResistor
Note: Images shown on this page are not to scale.

Parts List

  • Arduino Board
  • LDR. These can be purchased with different resistance ranges. See below for more details.
  • 10K Resistor
  • Breadboard hookup wires
  • USB Cable to suite Arduino

Circuit Diagram

LDR Sensor Hookup circuit

The easiest way to use the LDR is in voltage divider configuration. The voltage that appears at the analog input will vary depending on the amount of light hitting the LDR. The LDR can be connected to either 5V or 3.3V. The LDR appears as a variable resistor in the circuit below. We also use a 10K pull down resistor (R1).

Wiring Diagram for connecting the LDR to the Arduino Board

Wiring up the sensor requires only the ldr and a pull down resistor. We are using a 10K (R1) pull down resistor. We can wire up to the 5V or 3.3V power pin on the Arduino. It just means the voltage output to analog input when using the 3.3V power pin will be lower.

Connect Arduino to LDR Sensor Hookup

Breadboard Diagram for connecting the LDR to the Arduino Board

Connect Arduino to LDR Sensor Hookup using breadboard
Note: Images shown on this page are not to scale.


To test this sensor we can use sample sketch shown below. You can download the sketch file. It reads the LDR every 0.5 seconds and prints the results to the console on the computer connected to the USB port on the Arduino. We do not require any libraries for this sketch. The lower the value displayed the lower the light hitting the sensor. As more light hits the sensor the higher the value will be.

We are using analog pin A0 to connect to the sensor. If you are using a different analog pin then you will need to change the pin number defined on line 9 in the sketch code.

LDR Sample Sketch
Download as (Arduino Sketch) (Text File)
// Example Sketch for LDR (Light Dependent PhotoResistor). It reads the
// voltage at the LDR_Pin and displays it on the console. The value should
// range from 0 to 1024. The lower the value the lower the light. The higher
// the value means more light being received by the LDR.
// Written by For more details and how to hookup the LDR to the Arduino
// then visit this link.
int LDR_Pin = A0; // what pin on the arduino is the LDR output connected to
void setup(){
Serial.println("LDR Light Sensor Example Sketch |");
void loop(){

Sketch Output

Arduino to LDR Sensor Hookup Sample Sketch Output