LDR (Light Dependent Resistor) or Photo detector |
first we know about the LDR (Light Dependent Resistor) or Photo detector and how it works .
About LDR (Light Dependent Resistor) or Photo detector :
LDR (Light Dependent Resistor) or Photo detector is works based on light.the resistance of the LDR varies when light ibtensity is low and high , if the light value increase then the resitance of LDR (Light Dependent Resistor) or Photo detector decrease .if the light value decrease then resistance value increase this may the LDR works.
for more details watch the below video
LDR (Light Dependent Resistor) LED ON and OFF Arduino Program :
Components:
LDR (Light Dependent Resistor) LED ON and OFF CKT :
int ldrpin=A0;
int ldrvalue;
int led1=7;
int led2=8;
int del=1000;
void setup() {
// put your setup code here, to run once:
pinMode(ldrpin,OUTPUT);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
ldrvalue= analogRead(ldrpin);
Serial.println(ldrvalue);
if(ldrvalue> 100)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
}
if(ldrvalue < 100)
{
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
}
}
if you have any doubts regarding to this project, contact me on Instagram or comment on YouTube video. I will help my best.
0 Comments