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:
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:
Recording values of LDR sensor using Serial Monitor:
Step 1:
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.