LDR Sensor

LDR (Light Dependent Resistors) sensor is a light dependent sensor. It’s a type of resistor whose resistance vary on the amount of light falling on it. LDR sensor provide analog output depending on the amount of light in the environment in which sensor is located. LDR sensor basically contains 3 pins for analog input which is GND, VCC, SIG.LDR sensors are used to detect amount of light. LDR sensor sense light and convert the recorded binary values to analog. When the light increases the value increases and when the light decreases the value decreases.


Feature:

  • Easy to use
  • Cheap, Small and easily available
  • Used to sense Light
  • Easy to use on Breadboard
  • Available in PG5 ,PG5-MP, PG12,PG12-MP,PG20 and PG20-MP series

Pin Description:

     GND: use to provide ground to sensor

     VCC: use to provide power to sensor

     SIG: use to provide analog output to devices

Connections:

  •      Connect GND PIN to GND of Arduino
  •      Connect VCC PIN to 5V of Arduino
  •      Connect SIG PIN to any analog pin of Arduino(In this tutorial we will be using A0 PIN)

 

 

 

Recording values of LDR sensor using Serial Monitor:

Step 1:

  • Connect LDR sensor to Arduino UNO
  • GND of LDR to GND of Arduino
  • VCC of LDR to 5V of Arduino
  • SIG of LDR to A0 of Arduino

Step 2:

Copy and paste the code below in the Arduino IDE

int sensorPin = A0; // select the input pin for LDR

int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600); //sets serial port for communication
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
Serial.print("LDR Value:");
Serial.println(sensorValue); //prints the values coming from the sensor on the screen

delay(1000);

}

Step 3:

Open Serial Monitor in Arduino IDE

 

Conclusion:

You will see different values being printed on Serial monitor which is the analog value provided by the LDR sensor which depends upon the amount of light. You can try covering the sensor with your hands to see the change in values. Value increases with the amount of light and decreases with the amount of darkness.