3
3
Aim:ControllingrelaystatebasedonambientlightlevelsusingLDRsensor.
Procedure:Inthiscircuit,wearemakingaLightSensorusingLDRwith
Arduinotocontrolabulb/CFLasperlightconditionoftheroomoroutside area.
ComponentsRequired:
• ArduinoUNO
• LDR(LightDependentResistor)
• Resistor(100k-1;330ohm-1)
• LED–1
• Relaymodule–5v
• Bulb/CFL
• Connectingwires
• Breadboard
CircuitDiagramandConnections
LDR
LDR is Light Dependent Resistor.LDRs are made from semiconductor
materials to enable them to have their light-sensitive properties. There are
many types but one material is popular and it is cadmium sulfide (CdS). These
LDRs or PHOTO RESISTORS works on the principle of “Photo Conductivity”.
Now what this principle says is, whenever light falls on the surface of the LDR
(in this case) the conductance of the element increases or in other words, the
resistance of the LDR falls when the light falls on the surface of the LDR. This
property of the decrease in resistance for the LDR is achieved because it is a
property of semiconductor material used on the surface.
WorkingofLDRcontrolledLEDusingArduino
As per the circuit diagram, we have made a voltage divider circuit using LDR and100k
resistor. The voltage divider output is feed to the analog pin of the Arduino. The
analog Pin senses the voltage and gives some analog value to Arduino. The analog
valuechangesaccordingtotheresistanceofLDR.So,asthelightfallsontheLDR the
resistance of it gets decreased and hence the voltage value increase.
Intensityoflight↓-Resistance↑-Voltageatanalogpin↓-LightturnsON
ControllingRelayusingLDRwithArduino
InsteadofcontrollinganLEDaccordingtothebrightnessanddarkness,we can
control our home lights or any electrical equipment. All we have to do is
connect a relay module and set the parameter to turn ON and OFF the any AC
appliance according to the intensity of the light. If the value falls below 700,
which means it Dark, then the relay operates and the lights turns ON. If the
value is greater than 700, which means its day or bright, then the relay will not
operate and the lights remain OFF.
ArduinoCode
#definerelay10
int LED = 9;
int LDR = A0;
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(relay,OUTPUT);
pinMode(LDR, INPUT);
}
voidloop(){
int LDRValue = analogRead(LDR);
Serial.print(“sensor = “);
Serial.print(LDRValue);
if(LDRValue<=700)
{
digitalWrite(LED, HIGH);
digitalWrite(relay,HIGH);
Serial.println(“It’sDarkOutside;Lightsstatus:ON”);
}
else
{
digitalWrite(LED, LOW);
digitalWrite(relay,LOW);
Serial.println(“It’sBrightOutside;Lightsstatus:OFF”);
}
}
Output: