How can I create a smooth color fader animation with FastLED functions? Hello,

How can I create a smooth color fader animation with FastLED functions?

Hello, I want to create a simple color fader that just moves through each color via the HSV color system. Currently I am doing it this way:

loop() {
fill_solid(leds, NUM_LEDS, CHSV(hue++,255,255));
delay(…);
}

But it makes the animation look choppy at slower speeds (with a delay). I would expect the occuring colors to be something like the following:

rgb(255, 0, 0)
rgb(255, 1, 0)
rgb(255, 2, 0)
rgb(255, 3, 0)

but instead they are more like this (I didn’t test the exact values but the increments are much bigger like you can see):

rgb(255, 0, 0)
rgb(255, 4, 0)
rgb(255, 8, 0)
rgb(255, 12, 0)

Obviously the first method would give me a much smoother animation while I would have to adjust the speed.

Is there a FastLED function that I can use to replicate the upper behaviour without coding it myself? If not, what would be the easiest way to do it?

Thank you!

If you’re just modifying the hue part of the HSV color space, then that necessarily will be gappy, since it’s a single 8-bit number (hue) mapping to a 24-bit number (RGB).

To get what you want with FastLED, you can use the triwave8() function perhaps:

uint8_t i;
loop() {
uint8_t v = triwave8(i++);
fill_solid( leds, NUM_LEDS, CRGB( v, 85-v, 171-v);
delay(…);
}

The triwave8() func is described here: https://github.com/FastLED/FastLED/wiki/FastLED-Wave-Functions and my intent in code above is to fake the FastLED “spectrum” color cycle here: https://github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors