Blynk + ESP32 + WS2812B Controlling Brightness

Good Evening Everyone,

Hardware
I am currently trying to solve an issue that is coming up while trying to code my Blynk project. For reference, I am using an ESP32 Microcontroller (WiFi), Arduino Software, WS2812B 16*16 RGB Matrix, and of course an iPhone 8 Plus to control the color functions and brightness.

Overall Breakdown
I am trying to control the color of the WS2812B RGB Matrix while at the same time I want to control the brightness of the selected color thru the Blynk Application. I was able to code enough to a point where I could control the color of the RGB Matrix, although I wasn’t successful in coding the brightness color portion. I want to be able to control the brightness portion on the Blynk Application via the slider button. Any help would be very much appreciated as I have been searching for a couple days trying to find an answer. Thanks!

Code

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Adafruit_NeoPixel.h>
#include <SPI.h>


#define PIN 27
#define NUMPIXELS 256
#define BLYNK_PRINT Serial
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "HFppXh0Z78MF9ZPz2w-57f5nCgGG8A9g";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Kevin_2GEXT";
char pass[] = "6432yzab";

BLYNK_WRITE(V0)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V0 Slider value is: ");
  Serial.println(pinValue);
}

BLYNK_WRITE(V2)
{
  int R = param[0].asInt();
  int G = param[1].asInt();
  int B = param[2].asInt();
  Serial.println(R);
  Serial.println(G);
  Serial.println(B);
  for (int i = 0; i < NUMPIXELS; i++) {

    pixels.setPixelColor(i, pixels.Color(R, G, B));

    pixels.show();
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pixels.begin();
}

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

Hi, you can also use FastLED library for your application. Sample code is like this;

#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp32.h>
#define FASTLED_ESP32_RAW_PIN_ORDER
#include "FastLED.h"
#define NUM_LEDS1 120
#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
CRGB leds1[NUM_LEDS1];
char auth[] = "...";
char ssid[] = "...";
char pass[] = "...";
#define PIN1 12
int data=255;
int r,g,b;
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  FastLED.addLeds<LED_TYPE, PIN1, COLOR_ORDER>(leds1, NUM_LEDS1).setCorrection( TypicalLEDStrip );
}
 
BLYNK_WRITE(V3)       //zegbra 
{
  r = param[0].asInt();
  g = param[1].asInt();
  b = param[2].asInt();
 
  static1(r, g, b,data);
}
 
void loop()
{
  Blynk.run();
}
BLYNK_WRITE(V2)       //Slider for brightness 0-255
{
data = param.asInt(); 
static1(r, g, b,data);
}
void static1(int r, int g, int b,int brightness)
{
  FastLED.setBrightness(brightness);
  for (int i = 0; i < NUM_LEDS1; i++ )
  {
    leds1[i] = CRGB(r, g, b);
  }
  FastLED.show();
}