I am working on Automated Street Lighting System Using IoT project and using ThingSpeak for analytics. I have set Light status =100 when led is on and Light status=10 when led is off and its graph is being displayed on ThingSpeak. I want to detect the faulty bulb in my project such that when led(bulb) is disconnected from the breadboard,its Light_status should drop to 10 from 100.
Below is the code:
sensorvalue = analogRead(sensorPin);
Serial.println(sensorvalue);
if (sensorvalue < threshold) //threshold=90
{
Serial.println("LED light on");
digitalWrite(led1,HIGH); //switch on the light
int ledstate = digitalRead(led1);
if(ledstate!=HIGH)
** {**
** Light_status=10;**
** Serial.println("Fault");**
** }**
else
{
Light_status=100;
}
else
{
digitalWrite(led1,LOW); //switch off the light
Light_status=10;
}
Above code is working fine when led is connected but when I am disconnecting the led, there is no effect in the graph means Light_status from 100 is not getting dropped to 10.
It seems like that either the code above in bold letters is not executing or I am doing something wrong.