Hello, Is there a simple way to have a function FadeIn(leds[i]) which light a

Hello,

Is there a simple way to have a function FadeIn(leds[i]) which light a LED from black to any color, and the reverse function FadeOut(leds[i]) going to black from any color ?
I tried several function (fadeLightBy, nscale8, etc) and I the only result I can have is the fadeOut, but fadeIn is never working, the led remains black.
Thanks

How about Blend? For instance:

leds[i] = blend(CRGB::Red, CRGB::Blue, sin8(mysine));

If you use HSV then you can increase or decrease V based on a counter, or have it time based in some way.
leds[i] = CHSV(42,255, val);

Probably not the most efficient way but this is what I use on one of my projects. It allows for customizing the speed at which the fadein/out happens using a potentiometer or in my case an app on my phone.

@Andrew_Tuline , is mysine var changing from 0 to 1 or 255 to blend the value between Red to Blue ?

@marmil , good idea, I’m gonna try that :wink:

sin8 takes and outputs an unsigned char (uint8_t), 0-255.

@Stefan_Petrick did a nice example of the look of the different FastLED wave functions.

@marmil , thanks! Finally understood how does that work in between. But thanks for the video link explaining that. Is there a way to change the speed of the wave function without using delay() inside the loop ?

Multiply the value inside the parentheses by something less then 1 to make the period longer.
sin8( .5 * x ) will make the period twice as long.

missing/deleted image from Google+

I’ve also got a video on increasing performance in FastLED at:

Thanks! Everything is working well now :wink: