BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Use new ZeRGBa in advanced mode

Hello everybody

I’m playing with ZeRGBa but can’t get it to work.
I looked at all the old posts including my posts. The values are written to the serial console so BLYNK should work but the strip won’t light up. I probably don’t understand something about the code. Who can help me?

define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxxxxxxxxxxxxxx"
#define BLYNK_PRINT Serial

#include <BlynkSimpleEsp8266.h>
#define FASTLED_ESP8266_RAW_PIN_ORDER
#include <FastLED.h>

BlynkTimer timer; // Announcing the timer


#define NUM_LEDS  18
#define LED_PIN   14

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char pass[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";



#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
int data = 255;
int r, g, b;

void setup() {
  
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(40);
  timer.setInterval(10L, rainbow); //timer will run every sec
}



void loop() {
  
  Blynk.run();        // run Blynk magic
  timer.run();        // run timer every second
  
}



void rainbow(){

for (int i = 0; i < NUM_LEDS; i++) {
    //leds[i] = CHSV(hue, 255, 255);
    leds[i] = CHSV(hue + (i * 10), 255, 255);
  }
    hue++;
    FastLED.show();
}

void sinelon() {
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy(leds, NUM_LEDS, 20);
  int pos = beatsin16(13, 0, NUM_LEDS);
  leds[pos] += CHSV(hue, 255, 192);
  FastLED.show();
  /*FastLED.delay(1000 / varSpeed);*/
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  byte dothue = 0;
  for ( int i = 0; i < 8; i++) {
    leds[beatsin16(i + 7, 0, NUM_LEDS)] |= CHSV(dothue, 200, 255);
    dothue += 32;
  FastLED.show();  
  }
  /*FastLED.delay(1000 / varSpeed);*/
}



BLYNK_WRITE(V3)
{
  String r = param[0].asString();
  String g = param[1].asString();
  String b = param[2].asString();
  Serial.println(r);
  Serial.println(g);
  Serial.println(b);
  
  FastLED.show();
}


BLYNK_WRITE(V2)
{
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_LEDS; i++ )
  {
    leds[i] = CRGB(r, g, b);
  }
  FastLED.show();
}

Thank you

Are you referring h to this part of your sketch, is the ZERGBa widget attached to V3 ?…

If so, then I see two issues, your r, g and b variables are strings, which probably won’t work with FastLED, and you aren’t telling the FastLED library what to do with these values.

Pete.

Hi Pete

The problem was not blynk but the code to be modified on Fastled. Zergba now runs in advanced mode. I also had to insert a timer interrupt function (timer.disable (control_timer_rainbow):wink: otherwise the leds remained in rainbow mode and zergba didn’t work. I don’t know if putting timers this way is the best way but for now it works. I’ve entered all the correct code in case anyone needs it.

#define BLYNK_TEMPLATE_ID "XXXXX"
#define BLYNK_DEVICE_NAME "XXXX"
#define BLYNK_PRINT Serial

#include <BlynkSimpleEsp8266.h>
#define FASTLED_ESP8266_RAW_PIN_ORDER
#include <FastLED.h>

BlynkTimer timer; // Announcing the timer


#define NUM_LEDS  18
#define LED_PIN   14

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



#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
int data = 255;
int r, g, b;
int control_timer_rainbow;

void setup() {
  
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(40);
  timer.setTimeout(3600000L, [] () {} ); // dummy/sacrificial Function
  control_timer_rainbow = timer.setInterval(10L, rainbow); //timer will run every sec
}



void loop() {
  
  Blynk.run();        // run Blynk magic
  timer.run();        // run timer every second
  
}



void rainbow(){

for (int i = 0; i < NUM_LEDS; i++) {
    //leds[i] = CHSV(hue, 255, 255);
    leds[i] = CHSV(hue + (i * 10), 255, 255);
  }
    hue++;
    FastLED.show();
}

void sinelon() {
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy(leds, NUM_LEDS, 20);
  int pos = beatsin16(13, 0, NUM_LEDS);
  leds[pos] += CHSV(hue, 255, 192);
  FastLED.show();
  /*FastLED.delay(1000 / varSpeed);*/
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  byte dothue = 0;
  for ( int i = 0; i < 8; i++) {
    leds[beatsin16(i + 7, 0, NUM_LEDS)] |= CHSV(dothue, 200, 255);
    dothue += 32;
  FastLED.show();  
  }
  /*FastLED.delay(1000 / varSpeed);*/
}


BLYNK_WRITE(V3)
{
  timer.disable(control_timer_rainbow);
  FastLED.clear();
  r = param[0].asInt();
  g = param[1].asInt();
  b = param[2].asInt();
  Serial.println(r);
  Serial.println(g);
  Serial.println(b);
  for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB( r, g, b);
    }
  FastLED.show();
}


BLYNK_WRITE(V2)
{
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_LEDS; i++ )
  {
    leds[i] = CRGB(r, g, b);
  }
  FastLED.show();
}  


Thanks a lot

Best Regards

1 Like