A LDR (light dependent resistor) or a photo resistor is a device whose resistivity is a function of the incident electromagnetic radiation or in other words, photo resistor changes its resistance according to the ambient light in the room. They are also called photoconductors, or simply as we may put, photocells. They are made up of semiconducting materials having high resistance. As the light on the photocells increases, its resistance decreases and vice versa.
If we hook up the photo-resistor with with a fixed resistance in voltage divider circuit, we can essentially feed into the analog input of of the arduino a voltage that varies with the light in the room.
Symbol of LDR :-
WORKING PRINCIPLE :-
When photons are incident on the semiconductor(LDR) the electrons in the valence band are excited into the conduction band from the valence band. As the intensity of light increases more and electrons are excited into the conduction band hence the flow of current increases with the increase in light. The resistor has a very high resistance in dark rooms as there no energy available to excite the electrons. The resistance in a perfectly dark room is known as ‘Dark Resistance” and is very high up to 1kΩ.
These resistors have a very low- cost and are often used in camera lighting, street alarms, burglar alarms etc.
PHOTO_RESISTOR AS A LIGHT SENSOR :-
A voltage divider circuit using a photoresistor and 10k ohm resistor is buit. The analog input to the arduino board is fed through A0 pin. Therefore the analog input reads the voltage across the 10k ohm resistance. As the incident increases, the analog input voltage to the arduino increases and vice versa.
Whenever we first hook-up a sensor to the arduino we need to check the range of the data being recieved from the sensor. To do this we need to read the analog pin Ao and print the value to the serial monitor. This program is similar to the potentiometer project.
CIRCUIT ASSEMBLY :-
CODE AND EXPLANANTION :-
If you had noticed then you would have easily deduced that there isn’t much of a difference between the code of the potentiometer voltage sensing project and this one as, all we are doing is measure the voltage in both cases using different instruments.
Anyhow, the code required is :-
int sensorPin = A0; // analog input pin is initialized for reading the senor value
int sensoreValue = 0; // the value from where we should start the sensing. i.e zero
Serial.begin(9600); //opens the door to serial communication between a arduino and pc at a baud ratre of 9600.
sensorValue = analodRead(sensorPin); // reads the sensor value from the voltage divider circuit
Seial.println(sensorValue); //display the sensor value in the serial monitor
delay(100); // you can decide the time interval it may be 100 , 500, 1000 depending upon the lag you want between results