LDR Sensor Interfacing With Arduino Board

LDR Sensor Module Interfacing With Arduino Board is all about the Light Dependent Resistor (LDR). I’ll explain how it works and how to interface with Arduino and circuit diagram.


LDR Sensor:

           The Light Dependent Resistor (LDR) is just another special type of Resistor and hence has no polarity. Meaning they can be connected in any direction. They are breadboard friendly and can be easily used on a perf board also. The symbol for LDR is just as similar to Resistor but adds to inward arrows as shown above. The arrows indicate the light signals.

   The Photo resistors(LDR) is light sensitive devices most often used to indicate the presence or absence of light, or to measure the light intensity. In the dark, their resistance is very high, sometimes up to 1MΩ, but when the LDR sensor is exposed to light, the resistance drops dramatically, even down to a few ohms, depending on the light intensity. LDRs have a sensitivity that varies with the wavelength of the light applied and are nonlinear devices. They are used in many applications but are sometimes made obsolete by other devices such as photodiodes and phototransistors.

Based on the materials used, photo resistors can be divided into two types; 

(1) intrinsic

                    Intrinsic photo resistors use undoped materials such as silicon or germanium. Photons that fall on the device excite electrons from the valence band to the conduction band, and the result of this process are more free electrons in the material, which can carry current, and therefore less resistance. 

(2) extrinsic :

                      Extrinsic photo resistors are made of materials doped with impurities, also called dopants. The dopants create a new energy band above the existing valence band, populated by electrons. These electrons need less energy to make the transition to the conduction band thanks to the smaller energy gap. The result is a device sensitive to different wavelengths of light. 

    both types will exhibit a decrease in resistance when illuminated. The higher the light intensity, the larger the resistance drop is. Therefore, the resistance of LDRs is an inverse, nonlinear function of light intensity.

LDR Module Features:

=> Can be used to sense Light

=> Easy to use on Breadboard or Perf Board

=> Easy to use with Microcontrollers or even with normal Digital/Analog IC

=> Small, cheap and easily available

=> Available in PG5 ,PG5-MP, PG12, PG12-MP, PG20 and PG20-MP series


Circuit Diagram:


As shown in the image connect a LDR MODULE pin to Arduino-uno pins as Vcc to +5V, A-Out to A0,D-out to pin-2 and ground to Ground.

After connecting all the module as per the wiring diagram copy below arduino code and past  in Arduino IDE then compile sketch and upload code.

Arduino Code:

-----------------------------------------------------------------------------------------------------------------------

int LDR = 0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0

int LDRValue = 0,LDR_value = 0;      //that’s a variable to store LDR values

int light_sensitivity = 500;    //This is the approx value of light surrounding your LDR

 

void setup()

{

    Serial.begin(9600);       //start the serial monitor with 9600 buad

    pinMode(13, OUTPUT);     //we mostly use 13 because there is already a built in LED in arduino-board which shows output when 13 pin is enabled

}

 

void loop()

{

LDR_value = 0;

for(char i = 0;i<10;i++) // read avg. value of LDR.

{

LDR_value += analogRead(LDR);      //reads the ldr’s value through LDR

delay(30); 

}

LDRValue = /10;

Serial.println(LDRValue);       //prints the LDR values to serial monitor

delay(50);        //This is the speed by which LDR sends value to arduino

if (LDRValue < light_sensitivity) 

{

digitalWrite(13, HIGH);

}

else

{

digitalWrite(13, LOW);

}

delay(300);

}


-----------------------------------------------------------------------------------------------------------------------------

Now open the Serial terminal and check the result.when you turn ON and OFF the light Sensor value change according to light-intensity and display in serial port. you can change the value of " light_sensitivity = 500;  " as you required. you can do much more thing with LDR sensor like ON/OFF your Room Light according to Sun-light for saving energy.

Tutorial Video:

If This Tutorial Helpful For You Then Like and Subscribe To My you-tube Channel For More Helpful Tutorials, Thank you.

Post a Comment

0 Comments