Photo resistors, 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 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 photo-diodes and photo-transistors. Some countries have banned LDRs made of lead or cadmium over environmental safety concerns.
Widely used in cameras, solar garden lights, detectors, clock, dusk to dawn switchs and other light automatic opening OFF control field

Arduino Connections with Photo resistor module

Figure 1: Arduino Connections with Photo Resistor Module (LDR)

Arduino A2 –> Module Signal (S)
Arduino 5V –> Module +5V (Pin2)
Arduino GND –> Module GND (-)

Figure 2: Photo Resistor Module

Arduino Code for Photo Resistor Module

//KY018 Photo resistor module
 
int sensorPin = A2; // select the input pin for the potentiometer
int ledPin = 13;    // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  sensorValue = analogRead(sensorPin);
  digitalWrite(ledPin, HIGH);
  delay(sensorValue);
  digitalWrite(ledPin, LOW);
  delay(sensorValue);
  Serial.println(sensorValue, DEC);
}

The following Arduino sketch will output readings to serial monitor and also Pin 13 LED will flicker according to the light falling on sensor (LDR).

Responses