Firefly serial write question

unhandled

#1

Hi all,

i try to control addressable LED’s with firefly via the serial write and …hell it works WOW, but some challenges appears.

If i use the serial monitor from arduino all transmitted values are without time delay (or i dont see them)
If i use grasshopper with thefirefly serial write i can only transmit values with a min of 20ms and the leds starts blinking within this frequenz.

Arduino Sketch

#include "FastLED.h"
#define NUM_LEDS 3
#define DATA_PIN 6
CRGB leds[NUM_LEDS];


void setup(){
  Serial.begin(9600);
  delay(2000);
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
}


void loop() {
    while (Serial.available() == 0);
    int val = Serial.read()-'0';
    int numLedsToLight = map(val, 0, 9, 0, NUM_LEDS);

    // First, clear the existing led values
    FastLED.clear();
    for(int led = 0; led < numLedsToLight; led++) { 
                  
        leds[led] = CRGB::Blue;
        leds[led-1] = CRGB::Black; 
    }
    FastLED.show();
}

I guess i have to update the values only if the value change.
Maybe someone have similar tests and solution , will update here i it works.
Thanks to all who make this kind of magic interaction possible, a whole new world to explore.


#2
FastLED.clear();

is the reason , it works without blinking