I’ve managed to fade up the whole string to maximum brightness. However, the two fade-down options don’t seem to work very well. they are listed in the code. appreciate any advice
You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to mark up your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.
In fact, the IDE has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code” it can often be quite garbled and is always more difficult to read due to the font.
It is inappropriate to attach it as a “.ino” file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.
Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.
If EVERY_N_MILLISECONDS is non-blocking, your attempt to fade down will interfere with the fading up.
In a first step, I would only apply and show the updated brightness when it is time
void loop()
{
// delay(2000);
EVERY_N_MILLISECONDS(10)
{
// set new brightness
brightness ++ ;
// apply to strip
fill_solid(leds, NUM_LEDS, CHSV(255, 10, brightness));
//
FastLED.show();
}
}
If that works, you can use a variable to keep track if you want to go up or down and decide based on the value of that variable;
void loop()
{
static int8_t fadeStep = 1;
EVERY_N_MILLISECONDS(10)
{
// if the last time brightness was 255 or 0, change the direction from increase to descrease or vice versa
if (brightness == 255 or brightness == 0)
{
fadeStep *= -1;
}
brightness += fadeStep;
fill_solid(leds, NUM_LEDS, CHSV(255, 10, brightness));
FastLED.show();
}
}
Only thing that you have to change further is the initial value of brightness from 0 to 1 or to apply 0 brightness initially; below uses the latter in setup().