Using LDR ESP8266 Nodemcu LED Blinking

I Connected LRD in ESP8266 Nodemcu A0 pin , and a LED in D5 (GPO I14)

I used a conditional method ,
like , if LDR_Value <=50;
** digitalWrite(LedPin_1,HIGH);**
** else **
** digitalWrite(LedPin_1,LOW);**

but its not working , when the LDR value is less than 50 its not blinking LED.

i need help to run this LED using LDR in ESP8266 Nodemcu

the code is here,

const int LDR = A0; // Defining LDR PIN
int input_val = 0; // Varible to store Input values

int LED=14;

void setup() {
Serial.begin(9600);
pinMode(LDR,INPUT);
pinMode(LED,OUTPUT);
}

void loop() {
input_val = analogRead(LDR); // Reading Input
Serial.print("LDR value is : " );
Serial.println(input_val); // Writing input on serial monitor.
delay(1000);
if (analogRead(LDR) < 50){

}
else;{
digitalWrite(LED,LOW);
}
}

Why you think led should blink?

In addition, you are powering led without current limiting resistor. Probably you damaged the led.

1 Like

No, the LED is running fine, I checked the current flow in D5 pin and there is no current flow when LDR_Value < =50 .

how to blink that LED please suggest.

Why read it again?
Why not use input_val?

**I might be wrong thats why i asked for suggestion, **

so please help me to write the correct code please.

Ok, but it's better if you insert a resistor in the schematic.

In order to blink you have to cyclic switch on and switch off (if is a "normal" LED).
The easiest way is using delay() instruction, but it's the worst too.

Futhermore, in your code there is this error: the semicolon end the instruction and the code inside the curly brackets will be always executed.

else;{
digitalWrite(LED,LOW);
}

Check this tutorial also
Blink Without Delay | Arduino

I just wanted to point out that, even if you edit or delete the post, the history of what you wrote remains and your ways of relating to others are really rude.

I don't know how is the study path for become electrical engineer in your country, but in mine there are ALSO computer and programming exams to pass before becoming a graduate.
So help yourself and get back to studying because your programming mistake is really trivial and typical of true beginners (for which it would be understandable and acceptable).

No one will write the code here for you, especially if you are so disrespectful and snooty!

Doesn't the deleted post disappear after 24 hours so you can't review the edits?

Yes, but the 24 hours isn't up, and the damage is done.

One hour to go! :yawning_face: