PAGE 119 OF 150 · MICROCONTROLLERS & LEDS
Gamma Correction for LED Brightness
Our eyes see brightness non-linearly.
LED SYMBOLTriangle points from anode to cathode; the arrows show light leaving the part.
Why correct
Eyes judge brightness roughly on a curve, not a straight line. A PWM value of 128 is half the light but looks much brighter than half.
The fix
Corrected = (value ÷ 255) raised to about 2.2, times 255. So an input of 128 becomes about 56.
- Precompute the result in a lookup table of 256 numbers.
- Apply it to every colour channel.
- Fades then look even from dark to bright.
The extra effect is fewer steps at the dim end, so use 10 or 12-bit PWM for very smooth low light.
REMEMBER
Gamma correction makes fades look even.Try it yourself
Sketch the circuit on paper first, calculate the values, then build it on a solderless breadboard using a low-voltage supply. Measure with a multimeter before you make anything permanent.
Explore LED clocks, stopwatches and electronics at cosycom.com.