Aitchison College
Prep school, ICT Department
Topic: Light Dependent Resistor (LDR) Sensor
Grade: M2
Objectives:
Students will be able to
• Understand the use of LDR sensor with examples
• Learn more about connectivity with other components
• Identify changes in code according to different
projects
LDR Sensor
• An LDR or Light Dependent Resistor measures the intensity of
light
• It is a light sensitive sensor often used to indicate the presence or
absence of light
• LDR is also known as photo resistor, photocell, photoconductor
• It works on the principle of photo conductivity, increased electrical
conductivity caused by the presence of light
• When the LDR is placed in a dark place, it gives very high resistance
• When light falls upon the LDR its resistance decreases and
conductivity increases
Use of LDR Sensor
• The applications of LDR mainly include outdoor
clocks, street lights, light intensity meters and laser
security systems
• LDR is also used in some cameras to detect the
presence of the light
Burglar Alert Security System
Sun Tracking Solar Panel
Dusk to Dawn Light Magic
Connections
Question 1:
What is the function of LDR sensor?
To measure
intensity of light
Question 2:
What is another name for LDR?
Photo resistor
or
Photo cell
Question 3:
What is the principle on which LDR sensor
works?
Photoconductivity
Question 4:
What happens to resistance when LDR sensor is
placed in dark?
Resistance
increases
Question 5:
Which type of pin on Arduino UNO is used
to connect LDR’s data pin?
Analog pin
Coding:
#define led D1 Serial.print(“Its dark, turn
#define ldrpin=A0; on the lights”);
int value=0; Serial.println(value);
digitalWrite(led,HIGH);
void setup() {
}
Serial.begin(9600); else
pinMode(ldrpin,INPUT); {
pinMode(led,OUTPUT); Serial.print(“Its bright, turn
} off the lights”);
void loop() { Serial.println(value);
digitalWrite(led,LOW);
value=analogRead(ldrpin);
}
if (value>=500) }
{
Output:
How will you define the mode of ldrpin?
a) pinMode(ldrpin,INPUT);
b) Mode(ldrpin,input);
c) ldrpin(input);
d) ldrpin(output);
Which function will be used to read ldrpin?
a) analogInput();
b) digitalInput();
c) analogRead();
d) digitalRead();
What will happen if the output value is 900?
a) Light will turn off
b) Light will turn on
c) Error message
d) No effect
What will happen if there is no “=” in the
statement if (value>=500)?
a) Error message at 500
b) Light remains off at 500
c) Light turns on at 500
d) Loop will exit
What will be the output of statements?
Serial.print(“Its dark”);
Serial.println(value);
a) Its dark 950
b) Its dark
950
c) 950 Its dark
d) Its dark950
Recap
• Function of LDR Sensor
• Uses of LDR Sensor
• Connection of LDR Sensor
• Code for LDR Sensor
THANK YOU