Electronic – Change RGB leds intensity

ledmicrocontrollerpwmrgb

Sorry if this is too basic but I don't understand this issue.

Right now, using an MCU, I change the RGB colours of an LED strip with 3 PWM signals.
All colours works great .
The thing is, when I am trying to set the intensity of the light, I don't know how to do it.

So if, for example, I have RGB(15,170,230), then I want to slowly reduce the intensity of the light, keeping the same colour, how would I change the RGB to get that?

Best Answer

Start by scaling the R,G and B by the intensity value, for your example at 50% intensity you would set 15*0.5, 170*0.5, 230*0.5 (7, 85, 115).

The LEDs might have different non-linear responses, so you might need to tweak the scaling for perceived colour

In particular, at very low levels, you will suffer from rounding error. There is no easy way around this except by increasing the colour resolution (e.g. to 0-1000 instead of 0-250) or selecting devices with a more appropriate dynamic range for the application (brighter or dimmer LEDs).

Another alternative if you are using multiple devices is to switch a subset of the devices on to give different intensity levels, for example if you have 6 RGB LEDs you could switch 3 to (1,10,10) and 3 to (0,10,10) to add resolution, effectively (0.5, 10, 10) overall.