LDR SENSOR
LDR SENSOR:
LDR is a Light Dependent Resistor. It works on
the photoconductivity principle. It is one type of resistor whose resistance
varies depending on the amount of light falling on its surface. When the light
falls on the resistor's surface then the resistance changes. These resistors are often
used in many circuits where it is required to sense the presence of the light.We can interface LDR sensor with Arduino to detect the light.
Applications:
- It can be used in street lights.
- It can be used in mines areas.
- It can be used in hilly areas.
- By using laser, it can be used for safety purposes.
Sample Project Using Arduino:
In this we are going to turn ON/OFF the LED whenever the LDR sensor senses the light.
Materials Required:
- ARDUINO UNO Board
- LDR
- Relay
- Bulb
- Breadboard
Circuit Diagram:
int ldr = A0; //initialize LDR is connected to pin in A0
int ldrvalue = 0; //initialize value of LDR sensor is 0
int relay = 2; // initialize relay is connected to pin 2
void setup()
{
pinMode(ldr,INPUT); // Declare ldr as input
pinMode(relay,OUTPUT); // Declare realty as output
Serial.begin(9600); // Enabling serial monitor
}
void loop()
{
ldrvalue=analogRead(ldr); // Read value of ldr, store it in
ldrvalue
Serial.println(ldrvalue); // print ldr value in serial
monitor
if(ldrvalue<700) // checking ldr value
{
digitalWrite(relay,HIGH); // if ldr value
reaches specified value light can be turned on using relay
}
else
{
digitalWrite(relay,LOW); // if specified value
exceeds then light is turned off using relay
delay(200);
}
}
Comments
Post a Comment