Is it possible to adjust the brightness of just a few leds on a

(Steve Galle) #1

Is it possible to adjust the brightness of just a few leds on a strip independent from the global brightness value? I’m incorporating some fiber optic wire into a wearable matrix and the brighter the led it is attached to the better it works. I have the wire hooked up to just a few pixels and would prefer to keep the rest of the pixels at a lower brightness.

Any guidance appreciated!

(Chris Parton) #2

Hi Steve, before calling you could iterate over the leds array and call leds[i].fadeToBlackBy(x).

For example, if x is 0, no fading will occur, if x is 128 the LED will be at half the original brightness, and if x is 255 the LED will be black.

You can also call fadeToBlackBy on the part of your array, e.g. to fade LEDs 5-15 (as array indices): fadeToBlackBy(&(leds[5]), 10, 128);

(Daniel Cikic) #3

This may be what you’re looking for:

// Add a constant amount of brightness to all three (RGB) channels.

// Subtract a contsant amount of brightness from all three (RGB) channels.

(Chris Parton) #4

@Daniel_Cikic I’ve never used subtractFromRGB before, but I think it subtracts a constant value from each channel, which could change the look of the colour.

For example, CRGB(50, 255, 255).subtractFromRGB(50) would return 0,205,205, which has no red in it.

Just something to consider when testing it out :slight_smile:

(Daniel Cikic) #5

@Chris_Parton You’re right. For correct colors he’d probably have to do a hsv conversion. But for changes to a certain degree I don’t think this is really a problem. And somebody put this function in there for a reason. :smiley:
But maybe Steve is using HSV already, who knows…? ^^

Edit: Just saw this one the first time… should look at that page more often. :smiley:

// Adjust brightness to maximum possible while keeping the same hue.

Maybe this would be useful on the leds used with fiber optics?

(Chris Parton) #6

@Daniel_Cikic I agree, I think for lots of colours and reduction values the two methods would yield a similar result. I didn’t know that method existed, so thanks for introducing it to me :slight_smile:

(Steve Galle) #7

Thank you very much @Daniel_Cikic and @Chris_Parton I will report back with the results!

(Ken White) #8

@Steve_Galle - You can set the brightness level using:

leds[i] = CHSV( 160, 255, 255);

Set color from Hue, Saturation, and Brightness Value.


Here is a sketch that illustrates how to set the brightness level to make part of a ring brighter:

(Chris Parton) #9

No problem @Steve_Galle , looking forward to hearing about/seeing the result!

(Steve Galle) #10

Hey guys! Sorry it took so long to get back. I tried a few of the methods suggested without any luck and got distracted by other projects. I decided to take another crack at it today and found exactly what I was looking for.

Using demoreel100 as an example, i set
#define BRIGHTNESS 255
#define NUM_LEDS 12

and then in the loop() i put fadetoblackby() just before like so:

fadeToBlackBy( leds, 10, 240);;

This is exactly the effect I was looking for! It causes the first 10 leds to be very dim and the last 2 leds to be at max brightness.

Thank you everyone for your responses!

(Andreas Hopf) #11

@Ken_White Can one somehow also only change the brightness (the “v” part of HSV, if one wants to keep hue and saturation as they are (I write to the entire leds array from palettes and only want to darken/brighten random LEDs)? Something equivalent to:

leds[i] = CHSV(as is, as is, change V up/down);

The thing is that leds[i].addToRGB(20); can overshoot 255 and then all colour information is irretrievably lost.