Use menu widget

Hello everyone
I’m trying to insert a menu to select some led effects, below the code I used:

BLYNK_WRITE(V52) {                 //menu with three items
  switch (param.asInt())
  {
    case 1: { 
      Serial.println("Rainbow");
      rainbow();
      break;
    }
    case 2: { 
      Serial.println("Rainbow&Glitter");
      rainbowWithGlitter();
      break;
    }
    case 3: { 
      Serial.println("Confetti");
      confetti();
      break;
    }
    case 4: { 
      Serial.println("Sinelon");
      sinelon();
      break;
    }
    case 5: { 
      Serial.println("Juggle");
      juggle();
      break;
    }
    default:
      Serial.println("Nessuna Selezione");
  }
}

I entered the “void” like this


void rainbow() {
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, LED_NUMBER, gHue, varRainbowSpeed);
  FastLED.delay(1000 / varSpeed);
}

void rainbowWithGlitter() {
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) {
  if ( random8() < chanceOfGlitter) leds[ random16(LED_NUMBER) ] += CRGB::White;
  FastLED.delay(1000 / varSpeed);
}

void confetti() {
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, LED_NUMBER, 10);
  int pos = random16(LED_NUMBER);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
  FastLED.delay(1000 / varSpeed);
}

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

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


unfortunately it does not work I select the effect from the menu but nothing changes where am I wrong?
In my dashboard I have selected: virtual pin V52, data type = integer, Min = 0, Max = 1

Thank you

Best Regards

You have 5 cases (menu items) but your max value is 1 of V52 instead of 5…

1 other thing: in Blynk IOT the menu starts with 0 instead of 1, so you need to change the cases in your code with starting from 0 to 4…

Hi

I change in 0 to 4 but no work

Did you change the max value in the datastream?

I believe that the starting index is defined by the datastream, so min = 0, max = 4 should give parameter values of 0-4 when the various menu items are selected.

I suppose min = 5, max = 9 would give parameter values of 5-9

Pete.

I guess you’re right Pete, never tried that before… :blush:

Hi

This is my datastream


and this is the code.
I didn’t write the code I took a code from the forum and I’m trying to modify it. my programming knowledge is limited I don’t understand everything written in the code

/*Downloads, docs, tutorials: http://www.blynk.cc
    Blynk library is licensed under MIT license

 *******************************************/

#define BLYNK_TEMPLATE_ID "xxxx"
#define BLYNK_DEVICE_NAME "xxxx"
#include <FS.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <FastLED.h>
#include "settings.h"





char auth[] = "xxxxxxxxx";
char ssid[] = "xxxx";
char pass[] = "xxxxxxxx";


int varSpeed, varRainbowSpeed;
int testLEDnumber, varMemSave;
int arrayCurrent[5], arrayMemory1[5], arrayMemory2[5], arrayMemory3[5], arrayNightMemory[5];

WidgetTerminal terminal(vPIN_TERMINAL);
BlynkTimer timer;
CRGB leds[LED_NUMBER];

void setup() {
  /*WiFi.mode(WIFI_STA);*/
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(20, inizio); //timer della routine iniziale ogni 20ms secondo

 
  /*********** OTA *************/
 /* ArduinoOTA.setHostname(Guapa);
  ArduinoOTA.begin();
  /******** BOOT VARS **********/
  arrayCurrent[0, 255, 255, 255]; // Set starting sequence as rainbow mode
  varSpeed = 100; // Start on 100 fps
  varRainbowSpeed = 0;    // Start stationary
  /******** FASTLED ************/
  FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  FastLED.addLeds<LED_TYPE, DATA_PIN, LED_ARRANGE>(leds, LED_NUMBER);
  /******** READY **************/
  terminal.print(F("# Blynk v" BLYNK_VERSION ": "));
  terminal.println(F(" Device started"));
  terminal.flush();
}

// Elenco dei modelli da scorrere. Ciascuno è definito come una funzione separata di seguito
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};
uint8_t gCurrentPatternNumber = 0; // Numero di indice di quale modello è corrente
uint8_t gHue = 0; // "colore di base" rotante utilizzato da molti dei modelli

String CurrentHexRGB() {
  return String("#") + String(((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b, HEX);
}

BLYNK_WRITE(vPIN_HUE) {
    updateColours(arrayCurrent[0], param.asInt(), arrayCurrent[2], arrayCurrent[3]);
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB()); // colour step
}
BLYNK_WRITE(vPIN_SATURATION) {
    updateColours(arrayCurrent[0], arrayCurrent[1], param.asInt(), arrayCurrent[3]);
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB()); // saturation
}
BLYNK_WRITE(vPIN_BRIGHTNESS) {
    updateColours(arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], param.asInt());
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB()); // brightness
}
BLYNK_WRITE(vPIN_FPS) {
  varSpeed = param.asInt();
}
BLYNK_WRITE(vPIN_PRESET) {
  nextPattern();
}
BLYNK_WRITE(vPIN_COLOUR_RED) {
    updateColours(1, 0, 255, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_COLOUR_GREEN) {
    updateColours(1, 80, 255, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_COLOUR_BLUE) {
    updateColours(1, 152, 255, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_COLOUR_WHITE) {
    updateColours(1, 255, 0, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_MANUAL) {
    updateColours(param.asInt(), arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);
    updateWidgets();
}
BLYNK_WRITE(vPIN_SYNC_GHUE) {
  gHue = 0;
  varSpeed = 100;
  terminal.println(" | Sync'd gHUE ");
  terminal.flush();
}

BLYNK_WRITE(vPIN_OFF) {
    updateColours(1, 255, 255, 0);
    updateWidgets();
}
BLYNK_WRITE(vPIN_RAINBOWSPEED) {
    varRainbowSpeed = param.asInt();
    Blynk.virtualWrite(vPIN_RAINBOWSPEED, varRainbowSpeed);
}



BLYNK_WRITE(V52) {                 //menu with three items
  switch (param.asInt())
  {
    case 0: { 
      Serial.println("Rainbow");
      rainbow();
      break;
    }
    case 1: { 
      Serial.println("Rainbow&Glitter");
      rainbowWithGlitter();
      break;
    }
    case 2: { 
      Serial.println("Confetti");
      confetti();
      break;
    }
    case 3: { 
      Serial.println("Sinelon");
      sinelon();
      break;
    }
    case 4: { 
      Serial.println("Juggle");
      juggle();
      break;
    }
    default:
      Serial.println("Nessuna Selezione");
  }
}


BLYNK_WRITE(vPIN_NIGHTMODE) {
  if (param.asInt()) {
    arrayNightMemory[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
    updateColours(1, 152, 255, 100);
    updateWidgets();
  } else {
    updateColours(arrayNightMemory[0], arrayNightMemory[1], arrayNightMemory[2], arrayNightMemory[3]);
    updateWidgets();
  }
}
void updateColours(int m, int h, int s, int b) {
  arrayCurrent[0] = m;
  arrayCurrent[1] = h;
  arrayCurrent[2] = s;
  arrayCurrent[3] = b;
}
void updateWidgets() {
  Blynk.virtualWrite(vPIN_MANUAL,     arrayCurrent[0]);
  Blynk.virtualWrite(vPIN_HUE,        arrayCurrent[1]);
  Blynk.virtualWrite(vPIN_SATURATION, arrayCurrent[2]);
  Blynk.virtualWrite(vPIN_BRIGHTNESS, arrayCurrent[3]);
  //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
}

/****************************************************************************/

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



void inizio()
{
switch (arrayCurrent[0]) {
    case 1:
      fill_solid(leds, LED_NUMBER, CHSV(arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]));
      break;
    /*case 2:
      FastLED.clear();
      for (int led = 0; led < testLEDnumber; led++) leds[led] = CRGB::Blue;
      break;*/
    default:
      gPatterns[gCurrentPatternNumber]();
      EVERY_N_MILLISECONDS( 20 ) gHue++;  // slowly cycle the "base color" through the rainbow
      break;
 }
  FastLED.show();  
}






/****************************************************************************/
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern() {
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE(gPatterns);
}

void rainbow() {
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, LED_NUMBER, gHue, varRainbowSpeed);
  FastLED.delay(1000 / varSpeed);
}

void rainbowWithGlitter() {
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) {
  if ( random8() < chanceOfGlitter) leds[ random16(LED_NUMBER) ] += CRGB::White;
  FastLED.delay(1000 / varSpeed);
}

void confetti() {
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, LED_NUMBER, 10);
  int pos = random16(LED_NUMBER);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
  FastLED.delay(1000 / varSpeed);
}

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

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

thanks for the help but it doesn’t work in any way, i’m starting to think that with blynk 2.0 this programming is not right

You should add some serial print statements.

Pete.

I have a VU meter with 15 effects on a ESP32 using FastLED and converted it to run on Blynk (IOT), to get it working with Blynk i needed to put the switch cases in the void loop(). I don’t know your code well enough to know if this is going to work for you, but you can give it a try. See adjusted piece of your code

BLYNK_WRITE(vPIN_RAINBOWSPEED) {
    varRainbowSpeed = param.asInt();
    Blynk.virtualWrite(vPIN_RAINBOWSPEED, varRainbowSpeed);
}

int Effect =0; // put this in the part with your other int's in the code

BLYNK_WRITE(V52) {                 //menu with three items
Effect =  param.asInt();
}

BLYNK_WRITE(vPIN_NIGHTMODE) {
  if (param.asInt()) {
    arrayNightMemory[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
    updateColours(1, 152, 255, 100);
    updateWidgets();
  } else {
    updateColours(arrayNightMemory[0], arrayNightMemory[1], arrayNightMemory[2], arrayNightMemory[3]);
    updateWidgets();
  }
}
void updateColours(int m, int h, int s, int b) {
  arrayCurrent[0] = m;
  arrayCurrent[1] = h;
  arrayCurrent[2] = s;
  arrayCurrent[3] = b;
}
void updateWidgets() {
  Blynk.virtualWrite(vPIN_MANUAL,     arrayCurrent[0]);
  Blynk.virtualWrite(vPIN_HUE,        arrayCurrent[1]);
  Blynk.virtualWrite(vPIN_SATURATION, arrayCurrent[2]);
  Blynk.virtualWrite(vPIN_BRIGHTNESS, arrayCurrent[3]);
  //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
}

/****************************************************************************/

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

switch (Effect)
  {
    case 0: { 
      Serial.println("Rainbow");
      rainbow();
      break;
    }
    case 1: { 
      Serial.println("Rainbow&Glitter");
      rainbowWithGlitter();
      break;
    }
    case 2: { 
      Serial.println("Confetti");
      confetti();
      break;
    }
    case 3: { 
      Serial.println("Sinelon");
      sinelon();
      break;
    }
    case 4: { 
      Serial.println("Juggle");
      juggle();
      break;
    }
    default:
      Serial.println("Nessuna Selezione");
  }
}

Hi bazzio

ok now the widget works but mix effects, how do i stop one effect and start another?

Thank you

What do you mean with mix effects?
When selecting an option in the pull-down menu it should go and stay with that effect.
What does your widget look like, can you post a screenshot?

Hi

ok i managed to get something by looking in another post. (Menu widgets issues on Blynk 2.0). The part I corrected is this:

String MenuItem[5]={"rainbow","rainbowWithGlitter","confetti","sinelon","juggle"};

BLYNK_CONNECTED()
  {
  BlynkParamAllocated items(128);
  for (int i=0;i<10;i++) items.add(MenuItem[i]);
  Blynk.setProperty(V52, "labels", items);
  }


BLYNK_WRITE(vPIN_MENU) {   // Menu Widget on V52
  int index = param.asInt();
  switch (index)
  {
    case 0: {
     gCurrentPatternNumber = 0;
     break;
     }
    case 1: {
     gCurrentPatternNumber = 1;
     break;
     }
    case 2: {
     gCurrentPatternNumber = 2;
     break;
     }           
    case 3: {
     gCurrentPatternNumber = 3;
     break;
     }   
    case 4: {
     gCurrentPatternNumber = 4;
     break;
     }            
  }
}

Effects work by clicking the name of the effect on the menu. I still miss one thing, to make the effects work I have to click the “manual” widget (vPIN_MANUAL). immediately the “rainbow” starts and I can then change the effect from the widget menu. I would like the effects to start when I click on one of them without clicking “manual” first. But the code is complicated for me and I don’t understand what to add to my vPIN_MENU to do this. Who can help me?
Here is all the code that still works and could be useful to someone:

int statopinmanuale = 0;
int varSpeed, varRainbowSpeed;
int testLEDnumber, varMemSave;
int arrayCurrent[5], arrayMemory1[5], arrayMemory2[5], arrayMemory3[5], arrayNightMemory[5];

WidgetTerminal terminal(vPIN_TERMINAL);
BlynkTimer timer;
CRGB leds[LED_NUMBER];

void setup() {
  /*WiFi.mode(WIFI_STA);*/
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(20, inizio); //timer della routine iniziale ogni 20ms secondo

 
  /*********** OTA *************/
 /* ArduinoOTA.setHostname(Guapa);
  ArduinoOTA.begin();
  /******** BOOT VARS **********/
  arrayCurrent[0, 255, 255, 255]; // Set starting sequence as rainbow mode
  varSpeed = 100; // Start on 100 fps
  varRainbowSpeed = 0;    // Start stationary
  /******** FASTLED ************/
  FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
  FastLED.addLeds<LED_TYPE, DATA_PIN, LED_ARRANGE>(leds, LED_NUMBER);
  /******** READY **************/
  terminal.print(F("# Blynk v" BLYNK_VERSION ": "));
  terminal.println(F(" Device started"));
  terminal.flush();
}

// Elenco dei modelli da scorrere. Ciascuno è definito come una funzione separata di seguito
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};
uint8_t gCurrentPatternNumber = 0; // Numero di indice di quale modello è corrente
uint8_t gHue = 0; // "colore di base" rotante utilizzato da molti dei modelli

String CurrentHexRGB() {
  return String("#") + String(((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b, HEX);
}

BLYNK_WRITE(vPIN_HUE) {
    updateColours(arrayCurrent[0], param.asInt(), arrayCurrent[2], arrayCurrent[3]);
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB()); // colour step
}
BLYNK_WRITE(vPIN_SATURATION) {
    updateColours(arrayCurrent[0], arrayCurrent[1], param.asInt(), arrayCurrent[3]);
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB()); // saturation
}
BLYNK_WRITE(vPIN_BRIGHTNESS) {
    updateColours(arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], param.asInt());
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB()); // brightness
}
BLYNK_WRITE(vPIN_FPS) {
  varSpeed = param.asInt();
}
BLYNK_WRITE(vPIN_PRESET) {
  nextPattern();
}
BLYNK_WRITE(vPIN_COLOUR_RED) {
    updateColours(1, 0, 255, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_COLOUR_GREEN) {
    updateColours(1, 80, 255, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_COLOUR_BLUE) {
    updateColours(1, 152, 255, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_COLOUR_WHITE) {
    updateColours(1, 255, 0, 255);
    updateWidgets();
}
BLYNK_WRITE(vPIN_MANUAL) {
    statopinmanuale = param.asInt();
    updateColours(param.asInt(), arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);
    updateWidgets();
}
BLYNK_WRITE(vPIN_SYNC_GHUE) {
  gHue = 0;
  varSpeed = 100;
  terminal.println(" | Sync'd gHUE ");
  terminal.flush();
}

BLYNK_WRITE(vPIN_OFF) {
    updateColours(1, 255, 255, 0);
    updateWidgets();
}
BLYNK_WRITE(vPIN_RAINBOWSPEED) {
    varRainbowSpeed = param.asInt();
    Blynk.virtualWrite(vPIN_RAINBOWSPEED, varRainbowSpeed);
}


  
String MenuItem[5]={"rainbow","rainbowWithGlitter","confetti","sinelon","juggle"};

BLYNK_CONNECTED()
  {
  BlynkParamAllocated items(128);
  for (int i=0;i<10;i++) items.add(MenuItem[i]);
  Blynk.setProperty(V52, "labels", items);
  }


BLYNK_WRITE(vPIN_MENU) {   // Menu Widget on V52
  int index = param.asInt();
  switch (index)
  {
    case 0: {
     gCurrentPatternNumber = 0;
     break;
     }
    case 1: {
     gCurrentPatternNumber = 1;
     break;
     }
    case 2: {
     gCurrentPatternNumber = 2;
     break;
     }           
    case 3: {
     gCurrentPatternNumber = 3;
     break;
     }   
    case 4: {
     gCurrentPatternNumber = 4;
     break;
     }            
  }
}



BLYNK_WRITE(vPIN_NIGHTMODE) {
  if (param.asInt()) {
    arrayNightMemory[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
    updateColours(1, 152, 255, 100);
    updateWidgets();
  } else {
    updateColours(arrayNightMemory[0], arrayNightMemory[1], arrayNightMemory[2], arrayNightMemory[3]);
    updateWidgets();
  }
}
void updateColours(int m, int h, int s, int b) {
  arrayCurrent[0] = m;
  arrayCurrent[1] = h;
  arrayCurrent[2] = s;
  arrayCurrent[3] = b;
}
void updateWidgets() {
  Blynk.virtualWrite(vPIN_MANUAL,     arrayCurrent[0]);
  Blynk.virtualWrite(vPIN_HUE,        arrayCurrent[1]);
  Blynk.virtualWrite(vPIN_SATURATION, arrayCurrent[2]);
  Blynk.virtualWrite(vPIN_BRIGHTNESS, arrayCurrent[3]);
  //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
}

/****************************************************************************/

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



void inizio()
{
switch (arrayCurrent[0]) {
    case 1:
      fill_solid(leds, LED_NUMBER, CHSV(arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]));
      break;
    /*case 2:
      FastLED.clear();
      for (int led = 0; led < testLEDnumber; led++) leds[led] = CRGB::Blue;
      break;*/
    default:
      gPatterns[gCurrentPatternNumber]();
      EVERY_N_MILLISECONDS( 20 ) gHue++;  // slowly cycle the "base color" through the rainbow
      break;
 }
  FastLED.show();  
}






/****************************************************************************/
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern() {
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE(gPatterns);
}

void rainbow() {
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, LED_NUMBER, gHue, varRainbowSpeed);
  FastLED.delay(1000 / varSpeed);
}

void rainbowWithGlitter() {
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) {
  if ( random8() < chanceOfGlitter) leds[ random16(LED_NUMBER) ] += CRGB::White;
  FastLED.delay(1000 / varSpeed);
}

void confetti() {
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, LED_NUMBER, 10);
  int pos = random16(LED_NUMBER);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
  FastLED.delay(1000 / varSpeed);
}

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

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



Thank you everyone

Hi

I managed to get something, but now I’m very confused. look here:

String MenuItem[5]={"rainbow","rainbowWithGlitter","confetti","sinelon","juggle"};

BLYNK_CONNECTED()
  {
  BlynkParamAllocated items(128);
  for (int i=0;i<10;i++) items.add(MenuItem[i]);
  Blynk.setProperty(V52, "labels", items);
  }


BLYNK_WRITE(vPIN_MENU) {   // Menu Widget on V52
  int index = param.asInt();
  switch (index)
  {
    case 0: {
     Blynk.virtualWrite(vPIN_MANUAL, LOW); 
     gCurrentPatternNumber = 0;
     break;
     }
    case 1: {
     Blynk.virtualWrite(vPIN_MANUAL, LOW);
     gCurrentPatternNumber = 1;
     break;
     }
    case 2: {
     Blynk.virtualWrite(vPIN_MANUAL, LOW); 
     gCurrentPatternNumber = 2;
     break;
     }           
    case 3: {
     Blynk.virtualWrite(vPIN_MANUAL, LOW);
     gCurrentPatternNumber = 3;
     break;
     }   
    case 4: {
     Blynk.virtualWrite(vPIN_MANUAL, LOW);  
     gCurrentPatternNumber = 4;
     break;
     }            
  }
}



I entered in the code “Blynk.virtualWrite(vPIN_MANUAL, LOW);” and now my “manual” widget goes OFF but the effects don’t start. If I do the same thing from my smartphone (I click on manual with my finger) it works perfectly. in theory the “blink.virtualwrite” command should do the same thing I do on my smartphone. Where am I doing wrong? i really need help my knowledge is gone

thank you

You need to add a Blynk.syncVirtual(vPIN_MANUAL); after each Blynk.virtualWrite(vPIN_MANUAL, LOW); command.

I’d also recommend using 0 instead of LOW as it makes more sense to the reader.

Pete.

Hi Pete

Work!!! i didn’t know about the blynk.syncVirtual function
I solved everything

Thank you

1 Like