(Edited for clarity) I've got a question about setting the brightness on the demoreel.

(Edited for clarity) I’ve got a question about setting the brightness on the demoreel. In the sketch I’ve linked here, I’ve incorporated a button press and some twinkle options, which appear to have the brightness I want but the demo reel functions appear to be at full brightness. Specifically, I’ve defined BRIGHTNESS at 32 on line 17, which is reflected in the twinkle function since I used the same variable but the demo reel is still showing bright, I imagine @ 96 like Marc mentions. I thought the setBrightness on line 67 was a global setting? I apologize if I’m not using the correct terminology. Can someone help me understand? Thanks!

https://codebender.cc/sketch:432223

FastLED.setBrightness is a master brightness control, and it has a range of 0-255. Think of it as a multiplier that is applied on top of whatever an individual pixel is set to just before the pixel is actually displayed (and it happens automatically “under the hood”).

In the demo reel example BRIGHTNESS is set to 96.
#define BRIGHTNESS 96

Which is then fed into the setBrightness function:
FastLED.setBrightness(BRIGHTNESS);

This sets the master brightness to 96 out of 255, or 96/255 = .37 or 37% of whatever a pixel is set to.

So if for example you set pixel 0 to a full bright red:
leds[0] = CHSV(0,255,255)
And pixel 1 to a half bright red:
leds[1] = CHSV(0,255,128)

when the data is pushed out the master brightness will be applied on top of these brightness values resulting in:
leds[0] will be 255 * 96/255 = a brightness of 96 (37% of max)
and
leds[1] will be 128 * 96/255 = 48 (19% of max)

Note: You can (re)set FastLED.setBrightness any time you like in your program. So if you want to run a certain routine that looks better at a lower brightness you can set it lower, and then later if you want to go back to full brightness you can set it back to a value of 255.

Here’s an example I made the used two potentiometers to control hue and brightness. In the checkKnobs function at the very bottom the potentiometer is checked and the resulting value is fed into setBrightness.

Thanks so much Marc.

In my sketch (linked) I set the brightness at 32. It’s impacting the twinkle part of my sketch like I want, but not the other things from the demo reel. Sorry if I wasn’t clear about the specific question. I’ve edited my post for clarity. Thanks!

Sorry I didn’t follow your question last night. I understand what you’re asking about now and what you’re seeing.

In your Twinkles functions the brightness the pixels are set to is affected by the variable STARTING_BRIGHTNESS (example: on line 186). And that STARTING_BRIGHTNESS value comes from whatever BRIGHTNESS is set to (line 131). But!.. Then when the pixel is displayed the master brightness scale factor (BRIGHTNESS) is being applied on top of the current pixel’s value (thus reducing the brightness further).

In the function rainbow and rainbowWithGlitter the pixels are given a brightness value of 255 (instead of STARTING_BRIGHTNESS) so they are starting at full brightness before being scaled down by the master brightness.
You could fix this by updating the rainbow function so it fades the pixels down some:

void rainbow()
{
fill_rainbow( leds, NUM_LEDS, gHue, 32);
fadeToBlackBy( leds, NUM_LEDS, 255-BRIGHTNESS); // fade the whole strip down.
}

[Side Note: There is no way to specify brightness (or saturation) when using fill_rainbow. It always sets pixels to full saturation and full brightness, so you have to do something like the above if you want to reduce the pixels stored brightness value after using fill_rainbow.]

In the functions confetti and juggle the brightness is being set (hard coded) to 255. You could change the 255 to BRIGHTNESS (similar to how you did on line 148) so it will change as you change the value of BRIGHTNESS up top.

Thank you again Marc! I wrote my question late, too. :wink:

This is exactly what I was wondering how to do. Thank you so much!

You’re welcome. Good luck with the CRASH Space event! :slight_smile:

Ha! Are you local?

I went with a slightly different sketch but I wanted to have some options as examples. This is what I came up with for this weekend:

I’m sort of local. I actually used to live on Overland! But I live in Glendale now.

btw, I like the idea of using that thin foam for diffusion.

Thanks! You’re about as local as I am since I’m in Long Beach! I held a couple basic/intro events at my place last summer (see attached example) but CRASH is way more central for most people I know. I’m looking forward to it! :slight_smile: