FastLED Fade down works, how to fade up ?

Hi,

I have tried various ways of going from minimum brightness to full brightness I have also searched on the net and found snippets, but not a full working example.

As I am trying to keep this simple I include my fade down code. Which works.

On the internet I have found someone said that you can fade up using scale8, but I am unsure of where to put in the code I have and I assume an adjustment to the count to fade up ?

Thanks for any help I have spent at least 5 hours on this already trying various code.

Any help please.

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


void setup()
{

   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

   leds[0] = CRGB::MediumSpringGreen;
   leds[1] = CRGB::Purple;
   leds[2].red = 250;  leds[2].green = 100;  leds[2].blue = 10;

   FastLED.show();

 for(int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Purple;
    leds[i].maximizeBrightness(2);
    FastLED.show();
}
      delay(2000);      
}



void loop()
{

fadeall();

}



void  fadeall()

      { for(int i = 0; i < NUM_LEDS; i++)

        leds[i].maximizeBrightness(250) ;
        FastLED.show();
        delay(100);

      }

One of the big problems in using a library is that you are denied the opportunity to learn. You have to learn what all the functions and methods do but that learning is not transferable knowledge. To fade down you need to reduce the red, green and blue values in the display buffer. But you seem to use a method maximizeBrightness , so read the documentation to see if their is a minimizeBrightness method or try a negitave value in the method you use.

On the other hand you could code it properly.

HI,

Eventually I did find the correct way of doing this.

First in my code, you must have a number in 'FastLED_fade_counter' in my case I use 255 as this fades from maximum brightness, and then in a separate part of code not shown here I check if the counter has reached '0' so all LEDS are OFF.

Either of the above numbers can be changed to suit your project.

Hope this helps someone in the future !

void  Scene_fade_down ()
{

      for ( int i = 0; i < NUM_LEDS; i++)
          {
            leds[i] = CRGB::Magenta;  // Can be any colour.
            leds[i].maximizeBrightness(FastLED_fade_counter);  // 'FastLED_fade_counter' How low we want to fade down to 0 = maximum.
          }

            FastLED.show();
            FastLED_fade_counter -- ;  // Decrement

}

Confused! I though you said it was fading UP that didn't work? You don't fade up with a function called Scene_fade_down() do you?

Steve

HI Slipstick .. ooops

Sorry i have been doing a lot of coding and forgot that it was fade up.

Here's the code

void  Scene_01_fade_up ()

{

      for ( int i = 0; i < NUM_LEDS; i++ )
          {
            leds[i] = CRGB::Orange; // Can be any colour
            leds[i].maximizeBrightness(FastLED_fade_counter);  // 'FastLED_fade_counter' How high we want to fade up to 255 = maximum.
          }

            FastLED.show();
            FastLED_fade_counter ++ ;   // Increment

}
1 Like