Changing Brightness of LED

Hey Guys, is there a way to change the brightness of an LED without changing the color?
Let’s say I have this color (255, 100, 255), many people suggested that I lower the brightness by lowering the values such as this (155, 0, 155). That did lower the brightness but it changed the color. Do you guys know an easier and more practical way?

Are you refering to the Status RGB LED on each Particle device, or RGB LEDs in general?

For the Status LED you can use this: https://docs.particle.io/reference/device-os/firmware/photon/#brightness-val-

Take a look at the HSB color scheme. Those are controlled by Hue and Brightness separately. You can find functions that will convert that back into RGB so you can feed that to your Leds.

Seperate external LEDs that I connected to my photon.

Hey Moores, are you saying that my LED and Photon is unable to read HSB color schemes? and instead convert HSB values to RGB? Is there no way to make HSB readable by the photon and LEDs?

Your LEDs are driven by a PWM signal for Red Blue and Green LEDS, so RGB, not HSB. The same goes for any kind of display the ‘reads’ HSB: at some point, it’ll have to be converted back to RGB for the hardware to be able to work with it. Whether you do that manually or a library does that for you, it has to be done either way.

Thanks for clearing this up. Appreciate it!

You can use a potentiometer or a resistor to adjust the brightness.

For an RGB LED you’d need three of them, and color wouldn’t be uniform, nor would you be able to control the brightness from your code. As for a digital LED, that won’t work at all (as far as I’m aware).
Brightness control can be handled in code just fine :slight_smile:

A really simplified way to do this is to multiply by a fractional amount, so for 50%,

{255, 100, 255} * 0.5 = {127, 50, 127}

1 Like