LED widget not working

Hello everyone,
i am trying to making one small project which is based on arduino and esp8266, where i am interfacing LM35 sensor and reading value of temperature on gauge and i used one LED indicator for status after reaching the value more than 50 degree celcius. my indicator not working. i think my logic wrong.
please give me solution on it.

my blynk LED setting below in link

ardiuno code

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SimpleTimer.h>

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

char auth[] = "dXFQtDVi_B4rqAV7Nrx0GD3tg-jdqA1Q";
char ssid[] = "shubham";
char pass[] = "shubh@27";

//float vref = 3.3;
//float resolution = vref / 1025.0;
float temperature_L1;
float temperature;
#define ESP8266_BAUD 9600
WidgetLED led(V1);
SimpleTimer timer;
//BlynkTimer timer;

ESP8266 wifi(&EspSerial);
void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);  
  Blynk.begin(auth, wifi, ssid, pass);
  timer.setInterval(500L, blinkLedWidget);
  delay(10);
}

void loop()
{
  Blynk.run();
  timer.run();
}


void sendUptime()
{
  float temperature_L1 = analogRead(A0);//lm35 is connected to pin A0 on NodeMcu
  temperature = temperature_L1 * 4.88;     
  temperature = temperature * 10.0;
  Serial.print("LM35 temperature: ");//serial print the value 
  Serial.println(temperature);
  Blynk.virtualWrite(V0, temperature);//send the value to blynk application
}
void blinkLedWidget()
{
    if ( temperature >= 50 )
  {
   Blynk.virtualWrite(V1, HIGH);
  }
  else
  {
    Blynk.virtualWrite(V1, LOW);
  }
}

@Shubham_Ragit please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Once you’ve done that, we’ll tell you what the problem is and how to fix it.

Pete.

2 Likes

Led widget works as below (from Docs link):

sorry sir, but i am unable to edit my post pencil icon shows but not working with my post any other solution

i know the syntax please post again and code whats the issue

You managed to edit it two days ago…

You’ve also tried posting your code a second time, but rather than copying and pasting the triple backticks that I provided for you, you decided to try it with quotes instead - which doesn’t work.

Post your code, properly formatted, and we’ll tell you the changes you need to make.

Pete.

ok done sir please give me solution
thank you

Here’s what the documentation (which @psoro already shared with you) for the LED widget says:

LED

A simple LED for indication. You need to send 0 in order to turn LED off. And 255 in order to turn LED on.

All values between 0 and 255 will change LED brightness

In C++, HIGH or true = 1 and LOW or false = 0

This means that this line of code:

Is turning the LED widget attached to V1 on, but at brightness 1 out of 255. As a result, the LED is so dim that it appears to be off.

Replacing HIGH with 255 will fix your problem.

Also, sharing your Blynk auth code on a public forum is very bad practice, as it allows anyone to control your project. You should refresh the auth code within the app, and use the newly generated code in your sketch (and keep it private in future).

Pete.

ok, thank you so much sir i will take about auth code

Another easy way to do is to follow Blynk Docs by using functions:
led.off() and led.on()

exactly according to

Selection_357