This may come off as an absurdly simple question to some of you guys

This may come off as an absurdly simple question to some of you guys but i need to have a single WS2812B LED solid green fade from 128 brightness to 255 brightness and back again. Similar to a normal fade in Arduino. I tried modifying the rainbow pattern but i could never get anything to light up. Can you guys help me? This programming stuff reallt goes over my head :confused:

@Cristian_Martinez if you use the chsv color space it should be possible
x,y,z to setup a color and then make b vary from 128 to 255 and back. It should work

Check out the FastLED wave functions. @Andrew_Tuline had some examples.

To just cover just the range you want, you should be able to divide the 0 to 255 amplitude by 2 (which would then only return 0 to 127) and then add 128 to shift all the values up into the range of 128 to 255.

And you’ll have to search, I don’t know which ones.

Ok thank you so much! :slight_smile:

@marmil what would prevent this from being a possible solution to my problem?missing/deleted image from Google+

Im stuck at work for another 9 hours so i dont have a way to check my hand written code lol

Nothing would! There is usually always multiple solutions and that would certainly work as long as you don’t need to do anything else with that program, since the delays totally block other stuff from happening.

If you wanted to do something similar without any blocking you could use an EVERY_N block (which would allow the up/down rate to be adjusted).

uint8_t i = 127;
boolean direction = 1;

void_loop() {


if (boolean) { //going up
i++ ;
if (i == 0) { //it’s wrapped to 0
i = 255;
direction = 0; //toggle dir.

} else { //it’s going down
i-- ;
if (i == 127) {
i = 128;
direction = 1; //toggle dir.

fill_solid( leds, NUM_LEDS,
CHSV(85, 255, i) );;


//No delays, so no blocking.
//Can do other stuff here…


Paper code editor never fails.

Awesome! Ill give this a shot when i get home in the morning. I realize this would be much easier just using a 5mm green LED and the original fade code but i want to use FastLED for this lol :slight_smile: if everything works out ill upload a video of it working. Just need to print a few pieces to hold the button cell batteries and PCB :slight_smile:

I would do it something like:
int greenVal = 128+(sin8(millis()>>3))/2;
You will need to mess about with how much you divide/shift millis to make the timing better or go slightly more complicated and make it work every N millis style as above.

SWEET! i cant believe my hand written code works lol. I dont need it to do anything other than to fade thankfully but i really appreciate all the help and samples you guys have provided. I know they will come in handy in the future :slight_smile:

@Cristian_Martinez devicer nailed it using a wave technique. Definitely check that out to understand how it works.
And yes, type up the above versions and squirrel them away for another project. Always nice to have options.