BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk slider led

Good night, I realized that when using the blynk sliding widget to turn on a led, it doesn’t seem to turn on as indicated.
I verified this by creating a button to send 50% brightness and then it lights up more than if I sent 50% on the slider.
tested with virtual and digital pin.
how to fix?

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

BlynkTimer timer;

char auth[] = "";
char ssid[] = "";
char pass[] = "";

const int ledPin = 4;

BLYNK_CONNECTED() {

  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);

}
  
BLYNK_WRITE(V1){  
  int value = param.asInt();  
  analogWrite(ledPin, value); 
}

BLYNK_WRITE(V2)
 
{
int i=param.asInt();
if (i==1)
{

digitalWrite(ledPin, 127);
 Blynk.virtualWrite(V1, 127);
 }
  else
 {
   digitalWrite(ledPin, LOW);
    Blynk.virtualWrite(V1, 0);
}
}


void setup()
{
  Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
  pinMode(ledPin, LOW);
  pinMode(ledPin, OUTPUT);

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

Firstly, we need to see how your slider widget is set up in the app.

Secondly, the ESP8266 has a digital write range of 0-1023, so 50% brightness is 512, not 127.

Pete.

that was it … thanks, I didn’t know that esp8266 works in 1023

1 Like