Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

How LDR Sensor Works: Principle, Circuit & Arduino Guide

How LDR Sensor Works: Principle, Circuit & Arduino Guide
D
Written By Daniel D'Souza
📅 Updated on 25 Aug 2026
Summarize with AI
✅ Prompt copied

Summary

An LDR is a light-sensitive resistor whose resistance changes with the intensity of light falling on it. In a practical circuit, this resistance change is converted into a voltage that a microcontroller can read. 

This guide focuses on the technical implementation of how LDR sensor works, including the LDR working principle, voltage-divider calculations, resistor selection, circuit design, Arduino integration, module connections, calibration, and troubleshooting. For the basic definition, characteristics, types, and applications of LDRs, see our What Is an LDR Sensor? guide.

How LDR Sensor Works 

If you want to know how LDR works,the process starts with a change in light intensity. An LDR has a semiconductor material whose conductivity increases when exposed to light. 

The basic process is: 

  1. Light falls on the LDR. 
  2. Photons generate additional charge carriers in the semiconductor. 
  3. Electrical conductivity increases. 
  4. LDR resistance decreases.  
  5. The voltage across the circuit changes.
  6. A microcontroller reads this voltage and uses it as a light-level input.

This behaviour is called photoconductivity and forms the basis of the LDR working principle. 

In darkness, the LDR has high resistance. As the light becomes brighter, its resistance decreases. The exact resistance depends on the component, light intensity, wavelength, and operating conditions. 

Key Takeaway 

  • More light → lower LDR resistance 
  • Less light → higher LDR resistance 
  • A voltage-divider circuit converts this resistance change into a measurable voltage. 

Components and Supplies

Light Sensitive Photoresistor LDR - Light-dependent resistor for automation. -LDR Sensor -RobocrazeLight Sensitive Photoresistor LDR - Light-dependent resistor for automation. -LDR Sensor -Robocraze

    12mm Light Sensitive Photoresistor LDR

    Light Sensitive Photoresistor LDR - 12mm LDR Stands for Light Dependent Resistor and its Resistivity varies with Incident Electromagnetic Radiations so, its resistivity is a function of Incident Electromagnetic Radiations or light. Other names of LDR are photoresistor, Photoconductor, Photocell, and photo-conducting cell Read...
    Rs 36/-
    Rs 36/-
    Rs 44/-
    Save Rs 8/-
    5mm LDR (Light Dependent Resistor) - Photoresistor for light-sensitive projects. -LDR Sensor -Robocraze5mm LDR (Light Dependent Resistor) - Photoresistor for light-sensitive projects. -LDR Sensor -Robocraze

      5mm LDR (Light Dependent Resistor)

      5mm LDR (Light Dependent Resistor) A 5mm LDR photoresistor sensor is made of a high resistance semiconductor. If light falling on the device is of high enough frequency, photons absorbed by the semiconductor give the bound electron enough energy to jump into the conduction...
      Rs 10/-
      Rs 10/-
      Rs 17/-
      Save Rs 7/-
      LDR Sensor Module - Light-dependent resistor for brightness detection. -LDR Sensor -RobocrazeLDR Sensor Module - Light-dependent resistor for brightness detection. -LDR Sensor -Robocraze

        LDR Sensor Module

        LDR Sensor Module The LDR sensor module detects light and measures how bright it is. When there’s light, the output is high, and when there’s no light, it’s low. You can change how sensitive it is using a small dial (potentiometer). This light detection...
        Rs 31/-
        Rs 31/-
        Rs 64/-
        Save Rs 33/-

        How Does an LDR Work in a Circuit?  

        The LDR working principle becomes more useful when viewed as part of a complete electrical circuit. 

        An LDR does not normally produce a voltage by itself. Instead, it is connected with a fixed resistor to form a voltage divider. When light changes the LDR's resistance, the ratio between the two resistors changes, producing a different output voltage. 

        For example, if the LDR is connected between 5 V and the output node, with a fixed resistor connected from the output node to GND: 

        More light → LDR resistance decreases → output voltage increases 

        If the LDR and fixed resistor positions are reversed: 

        More light → LDR resistance decreases → output voltage decreases 

        This distinction is important when writing Arduino code because the direction of the analog reading depends on the circuit arrangement. 

        How to build a LDR Circuit Using a Voltage Divider 

        A basic LDR circuit can be built using only an LDR, a fixed resistor, a power supply, and a microcontroller analog input. 

        LDR Circuit Diagram 

        A typical LDR sensor circuit diagram contains four main connections: 

        5V → LDR → Analog Input → Fixed Resistor → GND 

        The analog input reads the voltage at the junction between the LDR and fixed resistor. 

        For the configuration above: 

        • LDR connects to 5V. 
        • The other LDR terminal connects to the analog input. 
        • Fixed resistor connects between the analog input and GND. 
        • The microcontroller measures the voltage at the junction.  

        This arrangement produces a higher analog reading as light intensity increases.

        LDR voltage divider circuit

        The standard voltage-divider equation is: 

        Vout = Vin × R2 / (R1 + R2) 

        If the LDR is used as R1, the equation becomes: 

        Vout = Vin × Rfixed / (RLDR + Rfixed) 

        Here: 

        • Vin = supply voltage 
        • RLDR = current LDR resistance 
        • Rfixed = fixed resistor 
        • Vout = voltage measured by the microcontroller  

        This is the basic LDR sensor circuit used in many light-detection projects.

        Example Calculation 

        Suppose: 

        • Vin = 5 V 
        • LDR resistance = 10  
        • Fixed resistor = 10   

        Then: 

        Vout = 5 × 10 / (10 + 10)

        Vout = 2.5 V 

        If the light becomes brighter and the LDR resistance falls to 2 : 

        Vout = 5 × 10 / (2 + 10)

        Vout ≈ 4.17 V

        The increase in output voltage can then be detected by an Arduino analog input. 

        How to Choose the Resistor for an LDR Circuit 

        Resistor selection directly affects the sensitivity and usable voltage range of an LDR circuit. 

        A practical approach is to select a fixed resistor close to the LDR resistance expected around the normal operating light level. 

        For example, if the LDR typically varies from approximately 2  to 50  in the intended environment, a fixed resistor around 10  can provide a useful voltage range. The ideal value depends on the required detection range.

        Choosing the Fixed Resistor 

        • Check the LDR's resistance range. 
        • Identify the expected lighting conditions. 
        • Choose a fixed resistor near the typical LDR resistance. 
        • Test the output voltage under minimum and maximum light. 
        • Adjust the value if the analog readings are too compressed.  

        The goal is not simply to choose the largest or smallest resistor. The resistor should provide useful voltage variation across the lighting conditions the project actually encounters. 

        Arduino LDR Sensor Connection 

        An Arduino LDR sensor setup is straightforward because Arduino boards provide analog input pins for reading variable voltages.

        arduino LDR sensor circuit

        For a basic LDR sensor connection, use: 

        LDR Circuit 

        Arduino 

        LDR + resistor junction 

        A0 

        Circuit VCC 

        5V 

        Circuit ground 

        GND 

         The Arduino reads the voltage at A0 using analogRead(). 

        On a standard 10-bit Arduino analog input, the reading ranges from 0 to 1023. The value represents the voltage at the analog input relative to the reference voltage. 

        For example: 

        int ldrPin = A0; 
         
        void setup() { 
          Serial.begin(9600); 
        } 
         
        void loop() { 
          int ldrValue = analogRead(ldrPin); 
         
          Serial.println(ldrValue); 
          delay(200); 
        } 

        Open the Serial Monitor and expose the LDR to different light levels. The readings will change as the resistance changes.

        Arduino LDR Sensor: Converting Readings to Voltage 

        The Arduino LDR sensor reading can also be converted into an approximate voltage. 

        For a 5 V reference: 

        Voltage = Analog Reading × 5 / 1023 

        For example, if Arduino reads 512: 

        Voltage ≈ 512 × 5 / 1023 

        Voltage ≈ 2.5 V 

        This is useful when calibrating an LDR sensor circuit because it allows you to compare the Arduino reading with the actual circuit voltage. 

        Keep in mind that the analog reading represents voltage, not LDR resistance directly. To calculate resistance, you need to use the voltage-divider equation and know the value of the fixed resistor.

        Calculating LDR Resistance from Arduino Readings 

        If the LDR is connected between 5 V and the analog input, and the fixed resistor is connected between the analog input and GND: 

        Vout = Vin × Rfixed / (RLDR + Rfixed) 

        Rearranging the equation: 

        RLDR = Rfixed × (Vin / Vout − 1) 

        Suppose: 

        • Vin = 5 V 
        • Rfixed = 10  
        • Arduino reading = 512 
        • Vout ≈ 2.5 V  

        Then: 

        RLDR = 10 × (5 / 2.5 − 1) 

        RLDR = 10  

        This provides a practical way to estimate the LDR's resistance from the Arduino analog reading.

        calculating LDR resistance

        Arduino LDR Sensor Code for Light Detection 

        For simple automation, you may not need to calculate resistance at all. A threshold can be applied directly to the analog reading. 

         int ldrPin = A0; 
        int ledPin = 13; 
         
        void setup() { 
          pinMode(ledPin, OUTPUT); 
        } 
         
        void loop() { 
          int ldrValue = analogRead(ldrPin); 
         
          if (ldrValue < 400) { 
            digitalWrite(ledPin, HIGH); 
          } else { 
            digitalWrite(ledPin, LOW); 
          } 
        } 

        The threshold of 400 is only an example. It should be calibrated according to the actual lighting conditions and circuit configuration. 

        This approach is useful for automatic lights, light-sensitive alarms, and simple Arduino LDR sensor projects. 

        LDR Sensor Module 

        An LDR sensor module combines the photoresistor with supporting electronics. A typical module can include an LDR, potentiometer, LM393 comparator, indicator LED, VCC, GND, and digital output. 

        Compared with a bare LDR, a module reduces the amount of external circuitry required. 

        Common uses include: 

        • Light and dark detection 
        • Automatic lighting 
        • Arduino projects 
        • Robotics 
        • Simple IoT systems  

        The LDR module is useful when you need a ready-to-use threshold-based light detector rather than designing the voltage-divider and comparator circuit yourself. 

        LDR Sensor Connection with a Module 

        A typical LDR sensor connection using a four-pin module is: 

        • VCC → Arduino 5V 
        • GND → Arduino GND 
        • AO → Arduino A0 
        • DO → Any suitable digital pin  

        LDR sensor module pin diagram

        AO provides a variable signal that changes with light intensity. DO provides a digital HIGH/LOW output based on the threshold set using the potentiometer. 

        For projects requiring actual light-level readings, AO is generally more useful. DO is convenient when the requirement is simply to detect whether the environment has crossed a particular brightness threshold.

        LDR Sensor Working in a Practical Project 

        A simple automatic street light demonstrates the LDR sensor working in a real application. 

        The LDR continuously detects ambient light. During the day, the circuit receives a high light level and keeps the lamp switched off. As the environment becomes darker, the sensor reading crosses a predefined threshold and the controller switches the lamp on. 

        This can be implemented using an Arduino, LDR, resistor, transistor or relay, and LED or lamp. The threshold should be calibrated based on the actual installation environment rather than using an arbitrary value. 

        LDR Sensor Working: Calibration 

        Calibration is important because LDR readings vary between components and environments. 

        A practical calibration process is: 

        1. Record the analog reading in bright conditions. 
        2. Record the reading in normal indoor conditions. 
        3. Record the reading in darkness. 
        4. Identify the readings at which the required action should occur. 
        5. Set the threshold between the relevant values. 
        6. Test the system under different lighting conditions.  

        Avoid calibrating the sensor under only one lighting condition. Shadows, direct sunlight, artificial lighting, and reflections can produce different readings.

        Troubleshooting an LDR Circuit 

        If an LDR circuit produces unstable or unexpected readings, check the following: 

        Problem 

        Possible Cause 

        Solution 

        Reading does not change 

        Incorrect wiring 

        Check the voltage-divider connections 

        Reading always near 0 

        Short circuit or wrong resistor arrangement 

        Check VCC, GND, and resistor connections 

        Reading always near maximum 

        LDR disconnected or incorrect wiring 

        Check the LDR terminals 

        Unstable readings 

        Electrical noise or changing light 

        Average multiple readings 

        Poor sensitivity 

        Incorrect fixed resistor 

        Select a resistor closer to the LDR's operating range 

        Wrong light/dark behaviour 

        Reversed voltage-divider arrangement 

        Check the position of the LDR and fixed resistor 

         

        If the circuit works but the threshold is inconsistent, recalibrate it rather than  immediately changing the hardware.

        Common LDR Sensor Project Ideas 

        The LDR sensor can be used in several practical projects without requiring complex hardware. 

        Automatic Street Light 

        Use an Arduino to switch a lamp or LED when ambient light falls below a threshold. 

        Light-Activated Alarm 

        Use a light source and LDR to detect interruption of a beam and trigger a buzzer. 

        Automatic Night Lamp 

        Use the LDR reading to turn an LED on when the surrounding environment becomes dark.

        Light-Tracking Robot 

        Multiple LDRs can be placed at different positions to compare light levels and control motor direction. 

        Smart Lighting System 

        Combine the sensor with a microcontroller and relay to automate room or outdoor lighting.

        If you appreciate our work and understand working of LDR sensor don't forget to share this post and leave your opinion in the comment box.

        Please do check out other blog posts about Popular electronics

        Make sure you check out our wide range of products and collections (we offer some exciting deals!)

        Excerpt

        Learn how an LDR sensor works, including its working principle, voltage divider circuit, resistance calculation, Arduino connection, module pin diagram and uses.

        Frequently Asked Questions

        How do you calculate resistance values for an LDR in a voltage divider?

        Use the voltage-divider equation Vout = Vin × Rfixed / (RLDR + Rfixed). Rearranging gives RLDR = Rfixed × (Vin/Vout − 1). Measure Vout with the Arduino analog input, use the known fixed-resistor value, and calculate the approximate LDR resistance.

        How does an LDR work in a circuit?

        An LDR changes resistance according to light intensity. In a voltage-divider LDR circuit, this resistance change produces a variable voltage. A microcontroller reads the voltage through an analog input and can use the reading to control LEDs, relays, motors, or other outputs.

        What resistor should I use with an LDR?

        A resistor close to the LDR's typical operating resistance is a practical starting point. For many basic circuits, 10  is commonly used, but the best value depends on the LDR's resistance range and the lighting conditions where the circuit will operate.

        How do I connect an LDR to Arduino?

        Connect the LDR and a fixed resistor as a voltage divider. Connect the divider output to an Arduino analogue pin such as A0, and connect the circuit to 5V and GND. Use analogRead() to measure the changing voltage and monitor the light level.

        What is the difference between an LDR and an LDR module?

        A bare LDR is only the light-sensitive resistor and requires additional circuitry for measurement. An LDR sensor module typically combines the LDR with a comparator, potentiometer, resistors, and indicator LEDs, making it easier to connect to Arduino and other development boards.

        How do I calibrate an LDR sensor?

        Record the sensor's readings under bright, normal, and dark conditions. Choose a threshold between the readings relevant to your application, then test it under different lighting conditions. Adjust the threshold if necessary to prevent false triggering from shadows or changing ambient light.

        Why is PV cell used in LDR circuit?

        Connecting an LDR sensor to a raspberry pi zero 2 w is relatively simple. 

        Is LDR active or passive?

        First, you will need the appropriate cables and connectors for connecting your components. 

        What is LDR made of?

        Depending on what type of output signal you're expecting from your LDR Sensor, either one or two GPIO pins of raspberry pi zero 2 w must be attached to it in order for communication between both devices to occur properly. 

        Does LDR obey Ohm's law?

        To connect the other end of these cables into the IO port of your raspberry pi zero 2 w, use compatible male-female jumper wires (or jumpers). 

        Which sensor is used in LDR?

        The LDR itself is a type of sensor used primarily for detecting light levels. In most applications, it is used in conjunction with other components, like microcontrollers or relay modules, to create a full sensing and response system for light-dependent applications.

        Are LDR sensors AC or DC?

        LDR sensors primarily work with DC (Direct Current) circuits. They are not designed to operate with AC (Alternating Current) as their resistance can vary rapidly, leading to inaccurate readings and potential damage to the sensor.

        Which principle is used in LDR?

        LDRs operate based on the principle of photoconductivity. This means that their electrical resistance decreases when exposed to light. The greater the light intensity, the lower the resistance, enabling them to effectively respond to changes in ambient light conditions.

        Prev Post
        Next Post

        Leave a comment

        Please note, comments need to be approved before they are published.

        Thanks for subscribing!

        This email has been registered!

        Shop the look

        Choose Options

        Edit Option
        Back In Stock Notification
        Compare
        Product SKU Description Collection Availability Product Type Other Details

        Choose Options

        this is just a warning
        Login
        Shopping Cart
        0 items
        FREE SHIPPING!
        ₹100 OFF
        ₹200 OFF
        ₹999
        ₹2500
        ₹4900
        WhatsApp Chat Chat