//DIGITAL READ
// When light is more the LDR will give less resistance
// When ambient light is less then LDR will give High Resistance
const int LDR = 12;
const int LED = 13;
int ldr_val = 0;
void setup()
{
pinMode(LDR, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop () {
ldr_val = digitalRead(LDR);
Serial.print("LDR Value is : ");
Serial.println(ldr_val);//prints the value of LDR
//the digital value from the LDR and the LUX is inversly Proportional
// when LUX is more the digital value will be 0, else it wil be 1.
// LUX = Illumination
delay(1000);
if (ldr_val==1)
{
digitalWrite(LED,HIGH);
delay(5000);
}
else{
digitalWrite(LED,LOW);
delay(5000);
}
}