Blynk Case Problems

Hello,
i have a Project where i need to Controll a LED Light, i want to make this i a menu tab (case). See Code for Problems :slight_smile:
Thanks

#define BLYNK_PRINT Serial
#define NUM_LEDS 10
#define PIN D6
#define FASTLED_ESP8266_RAW_PIN_ORDER       /* pin mapping for nodemcu v1.0 esp8266 */
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
#define FASTLED_ESP8266_D1_PIN_ORDER

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Blynk.h>
#include <FastLED.h>

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

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

CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2812B, PIN, RGB>(leds, NUM_LEDS);
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,1), 8080);
}

BLYNK_WRITE(V3) {
  switch (param.asInt())
  {
    case 1: // Solo
      BLYNK_WRITE(V1){
  
    
      int G = param[0].asInt();
      int R = param[1].asInt();
      int B = param[2].asInt();

     for(int i=0;i<NUM_LEDS;i++){
       leds[i].setRGB( R, G, B);
       FastLED.show();
        }
     }
    break;
    
    case 2: // Dual
     for(int i=0;i<NUM_LEDS;i++){
       leds[i].setRGB( 255, 0, 0);
       FastLED.show();
      break;
    
  }
}


BLYNK_WRITE(V2){                                     /*     Brightness     */
  
    int Brightness = param.asInt();
    FastLED. setBrightness( Brightness );
    FastLED.show();
  }






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



What’s this doing in the middle of your case 1 code?

Pete.

Its getting data from zeRGBa and controlls a W2812b led strip

The BLYNK_WRITE(V1) callback will only fire when the value of V1 changes via the app, so this approach won’t work.

Pete.

how can i get the data from V1 in case 1 ?

can you maybe write a sample code ?

  • Elias

When your device boots-up and connects to Blynk, do a Blynk.syncVirtual(V1) command and save the result in a global variable.
You can then reference that value within your case statement.

Pete.

I have a menu, this should select between which zeRGBa the data sent to the w2812b strips. I do not know how I can get the data from V1 into the case 1(V3). Can anyone make me a Sample Code.

Thanks.
-Elias