Slider doesn't change led brightness

Hello, I have a project to control rgbww LEDs with esp32 via the Blynk app, my problem comes when I want to adjust the brightness of the cold white led, the slider does nothing to the led.

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Blynk.h>
#include <analogWrite.h>
#include <EEPROM.h>

#define r_pri 12
#define g_pri 27
#define b_pri 25
#define c_pri 34
#define w_pri 32
#define r_sec 13
#define g_sec 14
#define b_sec 26
#define c_sec 35
#define w_sec 33

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

int rv1;
int gv1;
int bv1;
int pinw;
int pinc;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8080);

  pinMode(r_pri, OUTPUT);
  pinMode(g_pri, OUTPUT);
  pinMode(b_pri, OUTPUT);
  pinMode(c_pri, OUTPUT);
  pinMode(w_pri, OUTPUT);
  pinMode(r_sec, OUTPUT);
  pinMode(g_sec, OUTPUT);
  pinMode(b_sec, OUTPUT);
  pinMode(c_sec, OUTPUT);
  pinMode(w_sec, OUTPUT);
}

BLYNK_WRITE(V0) // primary color
{
  rv1 = param[0].asInt();
  gv1 = param[1].asInt();
  bv1 = param[2].asInt();  

  analogWrite(r_pri, rv1);
  analogWrite(g_pri, gv1);
  analogWrite(b_pri, bv1);
}


BLYNK_WRITE(V1) // secondary color
{
  int rv2 = param[0].asInt();
  int gv2 = param[1].asInt();
  int bv2 = param[2].asInt();  

  analogWrite(r_sec, rv2);
  analogWrite(g_sec, gv2);
  analogWrite(b_sec, bv2);
}

BLYNK_WRITE(V2) // warm white
{
  pinw = param[0].asInt();

  analogWrite(w_pri, pinw);
}

BLYNK_WRITE(V3) // cold white
{
  pinc = param.asInt();

  analogWrite(c_pri, pinc);
}

BLYNK_WRITE(V4) // RGB on/off
{
  int v = param.asInt();
  if(v == 0){
    analogWrite(r_pri, 0);
    analogWrite(g_pri, 0);
    analogWrite(b_pri, 0);
  }else{
    analogWrite(r_pri, rv1);
    analogWrite(g_pri, gv1);
    analogWrite(b_pri, bv1);
  }
  Serial.println(v);
}

BLYNK_WRITE(V5) // white on/off
{
  int v = param.asInt();
  if(v == 0){
    analogWrite(w_pri, 0);
  }else{
    analogWrite(w_pri, pinw);
  }
  Serial.println(v);
}

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

This should be pinw = param.asInt();

If that doesn’t solve the issue then add some serial print statements to see what values you are getting from the app.

Pete.

1 Like

ah, I missed that one.

But the V3 doesn’t trigger anything.


although it gets some value.

What does this mean?

Your serial output means nothing unless you post the code that created it.

Pete.

I just noticed that you are trying to use GPIO34 as an output, but pins 34 and higher are input only on the ESP32.

Pete.

thank you so much sir for helping me, now everything works fine

I’m really sorry if you don’t understand what I’m saying, it’s hard for me to explain in English.

1 Like