I'm using the FastLED library to control a digital RGB LED strip.

While this library seems very comprehensive in capability and ease of use, I do not yet see a way to simply set the brightness value of a individual pixel on an absolute scale. In other words, I want to simply set the brightness of a pixel, without passing a hue or saturation, and without it effecting other pixels.

FastLED.setBrightness() scales down the brightness of all pixels.
leds[i].fadeLightBy() scales down an individual pixel, but if it's called again for the same pixel before updating the LEDs, then the pixel will be faded again from it's already-faded value.

Is there truly no built-in method for setting the brightness of individual pixels to a particular value?

1 Answer 1


There is no dedicated function to adjust brightness.
You can (however) do this by using the HSV color model.

Breaking HSV (Anachronism) into Parts:

H (Hue) Controls the Color itself.
S (Saturation) of the Color.
V is called Lightness or Value.

'V' is what you want to control.
Just set the LEDs color to a HSV value and change it's V value.

leds[i] = HSV(color, saturation, brightness);

While 'Color' and Saturation' remain the same (to keep the same color), you can change the 'Brightness' directly on the third parameter.

Note that 'leds[i]' is still defined as 'CRGB', not as 'HSV'.
This assignment uses an implicit conversion, that is defined in the library.

You can see the 'HSV' usage example within the 'Cylon' example on the FastLED library.
There you will find the Hue value that gets changed; but it is the same principle as 'brightness'.

Now there is a problem to solve.
The FastLED library can convert 'HSV' Colors to 'RGB' Colors; but not the other way round.
So you cannot simply get the 'hue' and Saturation from an 'RGB' Color with this library.

You have 2 Alternatives:

1. You can just define an extra LEDs array with HSV colors and synchronize both arrays to contain the same data (everytime you want to change a color, you would set a 'HSV' color in the second array, convert that array to 'RGB' by using 'CRGB(hsv_leds[i])' and save that in the first array, which get's used by the FastLED library).
This is relatively easy, but you effectively need double the memory for storing the color values.
This is not an issue, if you have enough memory or few enough LEDs to control.

2. You can write your own function to convert 'RGB' values to 'HSV'; then use it to access the 'hue' and 'Saturation' values for the targeted 'RGB' Color, create a new 'HSV' Color with it and the new 'Brightness' and use it to set the 'RGB' values for the FastLED library.
In this forum thread there is a brief discussion about that, though it leaves you with the implementation yourself.
I think there are suitable implementations, that can be found on the web.
A quick search gave me this code from github gist. I have not tested it, so I cannot say, if it really works correctly, but you should give it a try. I'm sure there are also other implementations.

  • I realize that HSV let's you pass brightness, however I have applications that call for changing just brightness alone, given a certain trigger. It seems to me now that the solution is to do something like the following pseudo code: leds[i] = HSV(leds[i].color, leds[i].saturation, 127); so that I can manipulate the brightness to 127 without knowing offhand the current color, saturation, or brightness of that pixel at that time. I'll have to look around for the actual syntax of it. I certainly hope it can be done that way.
    – Bort
    Oct 27, 2019 at 20:03
  • @Bort I added a short explanation for that topic.
    – chrisl
    Oct 27, 2019 at 21:11
  • I think your answer is misleading when you say "you can just do exactly this" because I think your answer then goes on to explain that I cannot do that and I have to do something else. For your solution #1, why would I need to convert to RGB when the library already takes HSV as input? I'll try #2 in a bit.
    – Bort
    Oct 28, 2019 at 13:15
  • It's more of a "you can do exactly this, but it is a bit more complicated, than you wanted", since you can control the brightness of a single pixel with this, but it is more complicated than simply using one dedicated inbuild function. About #1: All examples, that I have seen, use CRGB as the array type, that is passed to the FastLED constructor. I tried using the construcktor with the HSV type, but that resulted in a corresponding compilation error. Thus I deducted, that the library works only with RGB, but also gives you HSV, which can then be converted to RGB
    – chrisl
    Oct 28, 2019 at 13:28
  • That deduction may be wrong. If you are able to directly use HSV for the array, please tell us and I will change my answer.
    – chrisl
    Oct 28, 2019 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.