Go Down

### Topic: Increasing Brightness Linearly (Read 1 time)previous topic - next topic

#### orangeLearner

##### Jul 27, 2013, 08:16 pm
I understand that LED brightness seems to be logarithmic as a function of duty cycle. In other words, perceived brightness = log(duty cycle) or that as the duty cycle becomes higher, the perceived differences in brightness become more imperceptible.

A person on the AVR Freaks forum posted this thread on how to use the formula "brightness = log(10^(duty cycle)) = x" to cancel out the log using a lookup table or linear interpolation.

Is there a name for this kind of "linearizing using the inverse"? I searched wikipedia and found "Inverse problem" but it got complicated really quickly with matrices and I couldn't follow.

#### robtillaart

#1
##### Jul 28, 2013, 01:20 am
what is the colour of the LED as IIRC these formulas depend on the colour too.

If you want to implement a lookup table check multimap() - http://playground.arduino.cc/Main/MultiMap -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### orangeLearner

#2
##### Jul 28, 2013, 03:17 am
My particular LEDs were green and white.

#3
##### Jul 31, 2013, 01:57 am
The logarithmic curve is only a relatively coarse approximation. More accurate is the CIE LAB correction:

http://neuroelec.com/2011/04/led-brightness-to-your-eye-gamma-correction-no/

This post on the forum explains how to calculate a lookup table:
http://forum.arduino.cc/index.php/topic,147810.0.html

You may want to check out "progmem":
http://arduino.cc/en/Reference/PROGMEM
http://trippylighting.com

http://ledshield.wordpress.com/

#### caiopoit

#4
##### Feb 16, 2018, 12:43 pmLast Edit: Feb 17, 2018, 10:31 am by caiopoit
Just to leave as reference in google searches, here's a little code that reasonably compensates our vision tendency and makes it seem like a linear brightness increase.

Code: [Select]

double LightLevel = 0;
double Base = 0.0039215;

while (LightLevel < 255) {  // 1020 increments up to 255
analogWrite(LightLevelPin, LightLevel);
LightLevel = pow(Base, 4) ;
Base = Base + 0.0039215;
}

#### septillion

#5
##### Feb 16, 2018, 01:30 pm
It's not a problem of the leds, it's a "problem" with our eyes. Double the duty the brightness does double. But our eyes don't see it as doubling.

What you want is gamma correction. I would not do it on the fly because the calculation is a bit heavy (not impossible but not easy for an 8-bit chip). In my library I use gamma correction as well
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake