We are Apogeeweb Semiconductor Electronic


Home arrow Resistors arrow Photoresistor: Basics and Arduino Tutorial

arrow left

arrow right

Photoresistor: Basics and Arduino Tutorial

Author: Apogeeweb
Date: 19 Jun 2020
photoresistor circuit

I Introduction

Photoresistor or light-dependent resistor (abbreviated as LDR) or photoconductor is a special resistor made of semiconductor materials such as cadmium sulfide or cadmium selenide. Its working principle is based on the internal photoelectric effect. The stronger the light, the lower the resistance value. With the increase of the light intensity, the resistance value decreases rapidly, and the bright resistance value can be as small as 1KΩ or less. The photoresistor is very sensitive to light, and it shows a high resistance state when there is no light, and the dark resistance can generally reach 1.5MΩ.


This article includes an overview of the basic information of the photoresistor and two Arduino tutorials for the photoresistor. The content is very comprehensive and detailed. You can choose the part you want to read or read the full text. We hope this article is helpful to you!



I Introduction

II What is a Photoresistor?

 2.1 Definition

 2.2 Symbol

 2.3 Composition

III How Does the Photoresistor Work?

 3.1 The Working Principle of Photoresistors

 3.2 Internal Photoelectric Effect

IV Photoresistor Application Circuit Diagram

V Types of Photoresistor

 5.1 Classification by Materials

 5.2 Classification by Spectral Characteristics

VI The Main Parameters and Basic Characteristics of the Photoresistor

 6.1 The Main Parameters of the Photoresistor

 6.2 Basic Characteristics

VII Arduino Photoresistor Tutorial

 7.1 LED Control with Photoresistor and Arduino

 7.2 Measuring Light Intensity Using a Photoresistor (Arduino)

 7.3 Use Experiment of Arduino Photoresistor

VIII How to Use Multimeter to Detect the Quality of Photoresistor?

IX A Quiz about the Photoresistor


II What is a Photoresistor?

2.1 Definition

According to Wikipedia, a photoresistor (also named LDR for Light Decreasing Resistance, or light-dependent resistor, or photo-conductive cell) is a passive component that decreases resistance with respect to receiving luminosity (light) on the component's sensitive surface.

2.2 Symbol

Photoresistors are generally represented by "RL", "RG" or "R". The following figure shows the schematic symbols of the photoresistor.

Photoresistor Symbol

Figure1. Photoresistor Symbol

Recommended Reading: To learn more about Resistor Symbol.

2.3 Composition

(1) The structure of the photoresistor

It is usually composed of a photosensitive layer, a glass substrate (or a branch moisture-proof film) and an electrode.

The Structure of Photoresistor

Figure2. The Structure of Photoresistor

  • Materials for manufacturing photoresistors

The materials used for manufacturing photoresistors are mainly semiconductors such as metal sulfides, selenides and tellurides. Usually, coating, spraying, sintering and other methods are used to make a very thin photoresistor and comb-shaped ohmic electrode on the insulating substrate, and then the lead is taken out and encapsulated in a sealed housing with a light-transmitting mirror to prevent moisture from affecting its sensitivity.

III How Does the Photoresistor Work?

3.1 The Working Principle of Photoresistors

How does a photoresistor work

The working principle of the photoresistor is based on the internal photoelectric effect.

A voltage is applied to the metal electrodes at both ends of the photoresistor, and a current flows through it. When irradiated with light of a certain wavelength, the current will increase with the increase of light intensity, thereby achieving photoelectric conversion. After the incident light disappears, the electron-hole pairs generated by the photon excitation will recombine, and the resistance of the photoresistor will return to its original value.

The photoresistor has no polarity and is purely a resistive device. It can be used with either DC voltage or AC voltage. The conductivity of a semiconductor depends on the number of carriers in the semiconductor conduction band.


  • Why is the value of the photoresistor related to the wavelength of the incident light?

Simply put, it is the effect of transitions between energy levels. Photons at different wavelengths have different energies, and an electron can only absorb one photon. After an electron absorbs a photon, whether it can be converted from non-conductive to conductive electrons depends on the photon’s Energy, and the number of electrons that can conduct electricity determines the resistance of the photoresistor. Therefore, the light wavelength also affects the resistance of the photoresistor.

Recommended Reading: See more about light sensor, wavelength, spectrum and photometric physical quantity.

3.2 Internal Photoelectric Effect

The internal photoelectric effect is a kind of photoelectric effect, mainly due to the effect of light quantum, which causes the change of the electrochemical properties of the substance (such as the change in resistivity, which is the difference from the external photoelectric effect, and the external photoelectric effect is the escape of electrons). The internal photoelectric effect can be divided into photoconductive effect and photovoltaic effect.



The photoconductive effect is one of two internal photoelectric effects. The internal photoelectric effect refers to the phenomenon that the electrical conductivity of a semiconductor exposed to light changes or a photo-induced electromotive force is generated. Among them, the phenomenon that the conductivity of the semiconductor changes due to light is called the photoconductivity effect.

Energy Level of Atom

Figure3. Energy Level of Atom

Photovoltaic Effect

From the principle of the transistor, it can be known that when the P-type semiconductor and the N-type semiconductor are combined together, the electrons in the N-type semiconductor and the holes in the P-type semiconductor diffuse with each other. As a result, a hole is formed near the interface of the P-N junction. The direction of the electric field is directed from the N-type semiconductor to the P-type semiconductor, as shown in the figure. When light irradiates the P-N junction and its vicinity, under the action of photons with sufficient energy, minority carriers (electron and hole pairs) are generated in and around the junction region.


After being excited, the electrons leave holes. Under the action of the internal electric field, the electrons flow to the N-type region, and the holes flow to the P-type region. This results in electron accumulation in the N-type region and hole accumulation in the P-type region. In turn, an additional electromotive force is generated at both ends of the P-N junction, that is, a photogenerated electromotive force. This phenomenon is the photovoltaic effect. If the P-N junction is connected with an external circuit, current will flow through the external circuit, and the direction of current flow is from the P region to the N region. This is the simple principle that the photovoltaic effect produces current or voltage.

Photovoltaic Effect

Figure4. Photovoltaic Effect

IV Photoresistor Application Circuit Diagram

  • Schematic circuit for conventional applications

Schematic Circuit

Figure5. Schematic Circuit

Module parameters:

  • Working voltage: DC3.3-5V
  • Photoresistor Model: 5516
  • Module pins: 3-pin or 4-pin (an additional analog output AO for 4-pin)
  • Common circuit diagram


(3)Photoresistor application circuit diagram

The following figure is a schematic diagram of the application of the photoresistor in the light control switch. The photoresistor is connected in series with the resistor R1. When there is no light, that is, the voltage across R1 does not reach the turn-on voltage of the Q1 transistor. Once exposed to light, the resistance of the photoresistor drops rapidly. The voltage across R1 rises and the transistor turns on, which causes the transistor Q2 in the subsequent stage to turn on, and finally, the switch K opens and the bulb works.

Common Photoresistor Application Circuit Diagram

Figure6. Common Photoresistor Application Circuit Diagram

(4) Photoresistor dimming circuit

The following figure is a typical light-controlled dimming circuit. Its working principle is: when the surrounding light becomes weak, the resistance of the photoresistor RG increases, which increases the partial voltage added to the capacitor C, which in turn makes the thyristor's conduction angle is increased to achieve the purpose of increasing the voltage across the lamp. Conversely, if the surrounding light becomes brighter, the resistance of RG decreases, resulting in a smaller conduction angle of the thyristor, and the voltage across the lamp decreases at the same time, dimming the light, thereby controlling the illuminance of the lamp.

Photoresistor Dimming Circuit

Figure7. Photoresistor Dimming Circuit

Note: The rectifier bridge in the above circuit must be a DC pulsating voltage, and it cannot be converted into a smooth DC voltage by capacitor filtering, otherwise the circuit will not work properly. The reason is that the DC pulsating voltage can not only provide the basic conditions for the zero-crossing shutdown of the thyristor, but also enable the charging of the capacitor C to start from zero every half cycle, and accurately complete the synchronous phase-shift triggering of the thyristor.

V Types of Photoresistor

5.1 Classification by Materials

Polycrystalline and single crystal photoresistors can also be divided into cadmium sulfide (CdS), cadmium selenide (CdSe), lead sulfide (PbS), lead selenide (PbSe), indium antimonide (InSb) photoresistors, etc.


5.2 Classification by Spectral Characteristics

(1) Ultraviolet photoresistor: sensitive to ultraviolet rays, including cadmium sulfide, cadmium selenide photoresistors, etc., used to detect ultraviolet rays.

(2) Infrared photoresistors: mainly lead sulfide, lead telluride, and lead selenide. Photoresistors such as indium antimonide are widely used in missile guidance, astronomical detection, non-contact measurement, human disease detection, infrared spectroscopy, infrared communication and other national defense, scientific research, and industrial and agricultural production.

(3) Visible light photoresistors: including selenium, cadmium sulfide, cadmium selenide, cadmium telluride, gallium arsenide, silicon, germanium, zinc sulfide photoresistors, etc. Mainly used in various photoelectric control systems, such as photoelectric automatic switch portals, automatic turning on and off of navigation lights, street lights and other lighting systems, automatic water supply and automatic water stop devices, automatic protection devices on machinery and "position detectors" Thickness detectors for thin parts, automatic exposure devices for cameras, photoelectric counters, smoke alarms, photoelectric tracking systems, etc.

Light Dependent Resistor

Figure8. Light Dependent Resistor

VI The Main Parameters and Basic Characteristics of the Photoresistor

6.1 The Main Parameters of the Photoresistor

1) Bright resistance (kΩ): refers to the resistance value of the photoresistor when exposed to light.

2) Dark resistance (MΩ): refers to the resistance value of the photoresistor when there is no light exposure (dark environment).

3) Maximum working voltage (V): refers to the highest voltage the photoresistor is allowed to withstand under the rated power

4) Bright current: refers to the current that the photoresistor passes when it is irradiated by light under the specified applied voltage.

5) Dark current (mA): refers to the current that the photoresistor passes under the specified applied voltage when there is no light.

6) Time constant (s): refers to the time required for the photoresistor to start from the light jump to stabilize 63% of the bright current.

7) Resistance temperature coefficient: refers to the relative change of the resistance value of the photoresistor when the ambient temperature changes by 1°C.

8) Sensitivity: refers to the relative change of the resistance value of the photoresistor with and without light irradiation.


Figure9. LDR

6.2 Basic Characteristics

(1) Dark resistance and bright resistance

  • The stable resistance value measured by the photoresistor under room temperature and total darkness is called dark resistance. The current flowing at this time is called dark current. For example, MG41-21 type photoresistor dark resistance is greater than or equal to 0.1M.
  • The stable resistance value measured by the photoresistor at room temperature and under certain lighting conditions is called bright resistance. The current flowing at this time is called the bright current. The bright resistance of MG41-21 type photoresistor is less than or equal to 1k.

    The difference between bright current and dark current is called photocurrent.

    Obviously, the larger the dark resistance of the photoresistor, the better, and the smaller the bright resistance, the better, that is, the dark current should be small and the bright current should be large, so the sensitivity of the photoresistor is high.

Bright Current and Dark Current

Figure10. Bright Current and Dark Current

(2) Volt-ampere characteristics

Under a certain illuminance, the relationship between the voltage applied across the photoresistor and the current flowing through the photoresistor is called the volt-ampere characteristic.


The volt-ampere characteristic of the photoresistor is approximately a straight line, and there is no saturation phenomenon. Due to the limitation of power dissipation, the voltage across the photoresistor cannot exceed the maximum operating voltage during use. The dotted line in the figure is the allowable power consumption curve, from which the normal operating voltage of the photoresistor can be determined.


(3) Photoelectric characteristics

    The relationship between the photocurrent of the photoresistor and the illuminance is called the photoelectric characteristic. The photoelectric characteristics of the photoresistor are nonlinear. Therefore, it is not suitable as a detection element, which is one of the shortcomings of the photoresistor. In automatic control, it is often used as a switching photoelectric sensor.

Characteristics of the Photoelectric Effect

Figure11. Characteristics of the Photoelectric Effect

(4) Spectral characteristics

For incident light of different wavelengths, the relative sensitivity of the photoresistor is different. The spectral characteristics of various materials are shown in Figure 2.6.4. It can be seen from the figure that the peak value of cadmium sulfide is in the visible light region, and the peak value of lead sulfide is in the infrared region. Therefore, when selecting the photoresistor, the types of components and light sources should be considered in order to obtain satisfactory results.


(5) Frequency characteristics

When the photoresistor is exposed to pulsed light, the photocurrent will reach a steady-state value after a period of time. When the light suddenly disappears, the photocurrent will not be zero immediately. This shows that the photoresistor has time-delay characteristics. Because different materials have different time delay characteristics of photoresistors, their frequency characteristics are also different. Figure 2.6.5 shows the relationship between the relative sensitivity Kr and the light intensity change frequency f. It can be seen that the use frequency of lead sulfide is much higher than that of thallium sulfide. However, most photoresistors have large time delays, so they cannot be used in situations where fast response is required. This is a defect of photoresistors.


(6) Temperature characteristics

Like other semiconductor devices, the photoresistor is greatly affected by temperature. When the temperature increases, its dark resistance will decrease. Changes in temperature also have a great influence on spectral characteristics. Figure 2.6.6 is the spectral temperature characteristic curve of the lead sulfide photoresistor. It can be seen from the figure that its peak value moves to the short wavelength direction as the temperature rises. Therefore, in order to improve the sensitivity, or in order to receive far-infrared light, cooling measures are taken.

Temperature Characteristics

Figure12. Temperature Characteristics

Spectral Temperature Characteristics of Lead Sulfide Photoresistor


A commonly used photoresistor is a cadmium sulfide photoresistor, which is made of semiconductor material. The resistance of the photoresistor changes with the intensity of the incident light (visible light). Under dark conditions, its resistance (dark resistance) can reach 1~10MΩ; under strong light conditions (100LX), its resistance (Bright resistance) Only a few hundred to thousands of ohms. The sensitivity of the photoresistor to light (the spectral characteristics) is very close to the human eye's response to visible light (0.4~0.76) μm. As long as the human eye can sense the light, it will cause its resistance to change. Therefore, when designing the light control circuit, the incandescent bulb (small electric bead) light or natural light is used as the control light source, which greatly simplifies the design.

Photoresistor Characteristic Curve

Figure13. Photoresistor Characteristic Curve

The corresponding resistance change of the photoresistor with the intensity of the incident light is not linear, so it cannot be used for the linear conversion of the photoelectricity. This is where the user should pay attention. Beginners can purchase a photoresistor (MG45 type), at night a 60~100W incandescent lamp, use a multimeter to directly measure the resistance of the photoresistor. When measuring, the photoresistor should be aimed at the light of the incandescent lamp, and then gradually distance from the lamp (from near to far), observe the change of the resistance value indicated by the multimeter, and the special characteristics of the photoresistor can be visually verified.

Commonly used photoresistor models are sealed MG41, MG42, MG43 and unsealed MG45 (cheap price). Their rated power is below 200mW.

VII Arduino Photoresistor Tutorial

7.1 LED Control with Photoresistor and Arduino

LED Control with LDR (Photoresistor) and Arduino

7.2 Measuring Light Intensity Using a Photoresistor (Arduino)

In the data collection of smart home, the measurement of light intensity is also very necessary. For example, the indoor lighting can be automatically adjusted according to the intensity of the light to provide users with the most comfortable learning and living environment. The tutorial here will use a photoresistor to cooperate with Arduino to complete the light data collection.

(1) Materials

  • Arduino UNO development board
  • Breadboard
  • Photoresistor
  • 1K-10K resistance

(2)Wiring method

 Wiring Method

Figure14. Wiring Method

The resistance of photosensitive resistors is very high in the condition of no light. The stronger the light, the smaller the resistance. By measuring the voltage variation on both sides of the photosensitive resistance, the variation of the photosensitive resistance can be known and the light intensity can be obtained. In the connection diagram, we find that a partial voltage resistor is connected in series for the photosensitive resistor.


Figure15. Circuit

In the above figure, RL is a photoresistor, R1 is a series resistor, Vout=RLR1+RLVin, in the dark, the resistance of RL will be very large, so Vout is also very large, close to 5V. Once the light is irradiated, the value of RL will decrease rapidly, so Vout will decrease accordingly. It can be seen from the above formula that R1 should not be too small, preferably around 1k~10k, otherwise the ratio will not change significantly.


(3) Code

The code part is very simple, just read the analog value of the interface connected to the photoresistor.

1 light = analogRead(0);

Open the serial monitor of Arduino, illuminate the photoresistor with the flashlight of the mobile phone, and observe the result:

2 Serial.println("lignt :");

3 Serial.println(light);

7.3 Use Experiment of Arduino Photoresistor

(1) Materials

  • Arduino UNO x1
  • Photoresistor x1
  • resistance 10K, 4.7K, 1K x several (or need one, but you can test the difference between different resistance values and data)

(2)Wiring method

 Wiring Method

Figure16. Wiring Method


#define AD5 A5 //Define analog port A5

#define LED 13 //Define digital port 13


int Intensity = 0;//Illuminance value


void setup() //Program initialization


   pinMode(LED, OUTPUT);//Set LED to output mode

   Serial.begin(9600);//Set baud rate 9600



void loop() // Program body loop


   Intensity = analogRead(AD5); //Read the value of analog port AD5 and save it in the Intensity variable

   Serial.print("Intensity = "); //Serial output "Intensity = "

   Serial.println(Intensity); //The serial port outputs the value of the Intensity variable and wraps

   delay(500); //Delay 500ms


(4) Power on, view serial data

Test Results:

Test Results

Figure17. Test Results

The above data is the change of the value with the flashlight and no light.

(5) Summary

The positive and negative poles are reversed and the values are reversed. The larger the resistance value, the larger the change range. Using 5V, the range is larger than 3.3V.

Recommended Reading: Arduino&mBlock light sensor

VIII How to Use Multimeter to Detect the Quality of Photoresistor?

  • Measure the dark resistance

Use a black piece of paper to cover the light-transmitting window of the photoresistor. At this time, the pointer of the multimeter remains basically unchanged, and the resistance value is close to infinity. The larger the value, the better the performance of the photoresistor. If this value is very small or close to zero, it means that the photoresistor has been burnt through and damaged and can no longer be used.

  • Measure the bright resistance value

Point a light source to the light-transmitting window of the photoresistor. At this time, the pointer of the multimeter should have a large amplitude swing, and the resistance value is significantly reduced. The smaller the value, the better the photoresistor performance. If this value is large or even infinite, it indicates that the internal open circuit of the photoresistor is damaged and can no longer be used.

  • Align the light-transmitting window of the photoresistor with the incident light, and use a small piece of black paper to shake the upper part of the light-shielding window of the photoresistor to make it receive light intermittently. At this time, the pointer of the multimeter should swing left and right with the black paper. If the pointer of the multimeter always stops at a certain position and does not swing with the shaking of the paper, it means that the photosensitive material of the photoresistor has been damaged.

IX A Quiz about the Photoresistor

Photoresistors, potentiometers, and thermistors are all ________.

A. Outputs

B. Digital inputs

C. Analog inputs

D. Throughputs

Answer: C


1. What is the use of LDR in a circuit?

LDR stands for Light Dependent Resistor and it offers a variable resistance value depending upon the illumination of light falling on it. It acts as a switch to control switching on or off an electrical circuit.


2. Does the resistance of an LDR vary with distance?

Yes, and the variation is to increase resistance as the distance to the light source increases, but not in a linear way; the resistance decreases with increasing light: R is proportional to L to the power of -alpha, where L is the illumination, in lux (i.e. lumens/square metre, or 1/10.764 foot-candles), and alpha is around 0.7 to 0.9 for Cadmium Sulphide LDRs. Unless the light source is some carefully focused parallel beam, the light intensity will normally decrease as the light source gets further away; for anything like a point-source the illumination drops off with the square of the distance, but in real-life torches with cheap, inexact reflectors or LEDs with lens-like curves will require a simple experiment to see what R vs distance curve you get.


3. What are the advantages of LDR (light-dependent resistors)?

The price of the LDR is less and there are different sizes & shapes which are available in the market.

In the practical LDR, there are different sizes are available and the most popular size is 100mm phase diameter.

The operation of LDR requires less power and voltage.

Limitations of LDR: They require a few milliseconds or more to respond fully to the changes in light intensity. They will take few seconds to return to their normal dark resistance once the light is removed. The sensitivity and resistance range of the LDRs will vary from one device to another.


4. What is the use of Photoresistor in Arduino?

A photoresistor or photocell is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity. A photoresistor can be applied in light-sensitive detector circuits, and light- and dark-activated switching circuits.


5. How is a Photoresistor used as a switch?

Ultimately, you're going to take the output of the photoresistor and convert it into a logic high or logic low, which turns your light on or off. If you need to flip this, one simple way is to take the digital output (assuming you are using a comparator) and pass it through an inverter, like a 74LS04 or equivalent.


6. Is the Photoresistor analog or digital?

A photo-resistor is fundamentally an analog component. They are usually used with a series fixed resistor to make a variable voltage source.


7. Why is a Photoresistor analog?

The analog input pin provides the signal that will be averaged. The resistance of a photoresistor decreases as the light incident on the face of the photoresistor increases.


8. What is the working principle of the Photoresistor?

When light falls on the photosensitive material (or on the Photoresistor), the valence electrons absorb the light energy and break free from the nucleus to become free electrons. These electrons lead to a flow of current when an external force like an electric field is applied.


9. What is the difference between photodiode and Photoresistor?

A photoresistor is less light-sensitive than a photodiode or a phototransistor. The latter two components are true semiconductor devices, while a photoresistor is an active component that does not have a PN-junction.


10. What does a Photoresistor measure?

Photoresistors, also known as light-dependent resistors (LDR), are light sensitive devices most often used to indicate the presence or absence of light or to measure light intensity. ... LDRs have a sensitivity that varies with the wavelength of the light applied and are nonlinear devices.


Best Sales of diode

Photo Part Company Description Pricing (USD)

Alternative Models

Part Compare Manufacturers Category Description

Ordering & Quality

Image Mfr. Part # Company Description Package PDF Qty Pricing (USD)

Related Articles


Leave a Reply

Your email address will not be published.

code image
Rating: poor fair good very good excellent

# 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z