/*Write a program to interface LED (light imetting daiode) at
PWM (pulse with modulation) pin and LDR (light dependent resistor),
in such a way that when the light intensity falling on LDR rises
the LED glow should be reduced and after a threshold value the LED
should be put off. (representing smart street light concept)*/
int led=5;
int ldr=A0;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(ldr, INPUT);
}
void loop() {
int ldrstatus=analogRead(A0);//LDR status value is 250.
if(ldrstatus <=400)
{
digitalWrite (led,HIGH);
Serial.println(ldrstatus );
}
else
{
digitalWrite (led,LOW );
Serial.println(ldrstatus);
}
}