Hi
I’m trying to figure out if I’m doing the right thing. I have this code in my “void loop()”
void loop(){
Blynk.run();
timer.run();
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();
}
The Blynk rules say that the “void loop ()” must be clean but I need the code to be repeated very quickly otherwise the leds don’t work as they should.
So I fixed the code like that
I used blynktimer and in the void setup() add this:
timer.setInterval(20L, inizio); //timer della routine iniziale ogni 20ms secondo
and then I cleaned the “void loop ()” like this
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();
}
everything seems to work fine. I wanted an opinion from you if it is the right way because I had to insert a timer of only 20ms to obtain acceptable effects on the LEDs. Could such a fast timer give Blynk any problems?
Thank you
Best Regards