Photocell (LDR) Sensor with Arduino

8,046 views

Introduction:

A photocell sensor is a type of resistor that changes its resistance based on the amount of light intensity experienced. It converts the light energy into electrical energy to produce voltage or current. The resistance of the device is inversely proportional to the amount of light intensity that is the resistance decreases with the increase in the amount of light. These are inexpensive, consume less power and are easy to use. They might be referred to as LDR (light dependent resistor) or photoresistors.

There are different types of photocells like photovoltaic, photoresistor, photomultiplier, charged couple devices and Golay cells. In the circuit given below, we have used LDR (Light-dependent resistor) made from a semiconductor material that makes them light-sensitive. This circuit is useful for different purposes and is easy to build and operate.

Hardware Requirement:

The hardware required for this circuit include:

S.noComponentValueQty
1.ArduinoUNO1
2.Photocell (LDR) sensor1
3.LED1
4.Resistor10KΩ1
5.Wire
Component List

Circuit Diagram:

The circuit diagram for the circuit is given below:

Photo-cell-LDR-sensor-circuit
Photocell sensor with Arduino circuit diagram

Construction & Working:

One pin of the LDR is connected to the power pin (5V) and another pin to the analogue pin of the Arduino board. The resistor is connected in between the analogue pin to the ground terminal. An LED is connected to the digital pin of the Arduino board and ground.

The analogue pin gives an analogue value to the controller on sensing the voltage converted by the sensor when the light is incident on it. The analogue value is dependent on the resistance of the LDR. Hence, as the light falls on the sensor, the voltage increase and the resistance decreases.

Source Code:

ketch code for Arduino photocell sensor.


int ledPin = 3;
int photocell = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
photocell = (analogRead(0)/4); // Divides input 0-1023 to resemble to 0-255
analogWrite(ledPin, photocell);
Serial.print(photocell);
// The required dimming effect can be obtained by changing the delay
delay(20);
}

Applications:

Photocell sensors can be used in a c=variety of applications. Some of them are:

  • They are used for the counting of objects or products on the conveyor or packaging line in industries.
  • They can be used for the counting of vehicles on the road.
  • They determine the intensity of light and thus can be used in Lux-meters.
  • Furthermore, they are applicable in the automatic doors to detect the presence of any human.
  • Not only that but they can also be used to reproduce the sound recorded in a movie.