# How to control the display's backlight in the sketch?

Okay but here: http://arduino.cc/en/Tutorial/PWM

This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) [...] The result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.

So I supposed, limiting the PWM as in my code, will output a steady 3.3V. :zipper_mouth_face: Then, I used a led resistor calculator (the parallel calculator, since I suppose the LEDs of my display are mounted parallel)... which tell me that I need a resistor of 1 Ohm (AKA: I don't even need a resistor), when the input voltage is the same as the forward voltage of the LED, and doesn't matter how much current I enter as the "desired LED current".

Guys, I'm lost...

Why do they always fight "the resistor"? Why resist? Is it "the expense"?

I don't, in fact I planned to add a resistor since the first post. I'm just wondering why I need one when a calculator tell me otherwise.

Put simply, I don't see what is the difference between these two:

``````PWM 66%  ---------> LEDs
PWM 100% ---[R]---> LEDs
``````

when the input voltage is the same as the forward voltage of the LED

But that's the wrong assumption.

If you look at the page you linked to, the pwm waveform has a voltage output of either 5v or 0v, at any given point. If you were to held a steady 5v to your 3.3v led, it would have burned out quickly.

What pwm is doing to leds is to turn on the leds, abusively at 5v, quickly. Because of pov, the led looks dimmer when the duty cycle goes down.

The nice thing about diodes is that they are very good at taking high peak current for a short period of time - sometimes 100x or 200x of their rated current.

when the input voltage is the same as the forward voltage of the LED

In addition to everything in the previous post you have to also understand that:

(1) You do not know what the forward voltage of the LED might be.
(2) Even if you determine what it is for one diode under one particular set of circumstances it would be different …
(a) for a different diode under the same circumstances.
(b) for the same diode under different circumstances.
(c) for a different diode under different circumstances.

In other words - if you to try to design a circuit to drive an LED with some specific voltage you are doomed to failure.

Did you ever consider why it takes so long to earn an Engineering degree?

Don

Did you ever consider why it takes so long to earn an Engineering degree?

Ouch. That's harsh.

Why do they always fight "the resistor"?

Nothing says that you have to have resistors. All you need to know is why you may need resistors and what risks you are running without resistors, so that you can make an informed decision.

Ok, another try (before I give up :))

In this exact situation (for now, I don't need to know in other circumstances..), let's say my multimeter show: 20 mA

3.3V, 20 mA, no resistor between Arduino's 3.3v pin and LED-A pin. There may be a resistor between LED-A pin and LEDs, or not, I don't care.

So for 5V, using a PWM output instead of the trimmer, I would just need to add a resistor of value (5-3.3) / 0.02A = 85 Ohm, between the PWM output and LED-A pin.

Am I wrong once again?

I’ve attached what looks like info on that shield including datasheets, manuals, library, and example code.

I found more than one document so I attached them both. Some are different, some are the same.

ITDB02_Graph16.rar (1.4 MB)

32lcd.zip (1.06 MB)

codlink, thanks for trying to help but I already have those documents: there is nothing in them, about backlight :)

Eh, ok, I didnt look through them…

let's say my multimeter show: 20 mA

The answer will depend on your multi-meter. If it is a multimeter that reads "average" (an analog meter or an rms meter (not quite but close)), your math then works.

I think you are overthinking this. Put a resistor (start with something safe like 330) in, power it to rail (5v), and find a resistor value that gives you more light than you want, as your pwm will dial back the (average) current later.

Then you are done.

Then, I used a led resistor calculator (the parallel calculator, since I suppose the LEDs of my display are mounted parallel)... which tell me that I need a resistor of 1 Ohm (AKA: I don't even need a resistor), when the input voltage is the same as the forward voltage of the LED, and doesn't matter how much current I enter as the "desired LED current".

Because these calculators are very simple minded and do not take into account extremes like you have in that situation. As well as considering the average current then you have to consider the peak current. This is the maximum instantaneous current that will flow in any given situation. With PWM this peak voltage is 5V no matter what the duty cycle gives you. Therefore you have what 5V will drive through the LED. This will be limited by the impedance of your source, in this case the arduino pin. However remember that the data sheet says the absolute limit you should draw from a pin is 40mA. Anything at this level or over this level will damage your pin. You might not see that damage immediately or even in a month or two but the circuit around that pin will die sooner than it otherwise would. In my tests with an arduino I have found that you can get 250mA peak current from an arduino pin, more than enough to damage it and possibly damage any LED connected to it.

Now you can totally ignore the data sheets and do what you want and your individual device may or may not fail immediately, maybe next month, next year or never. But if you take a large number of devices abused in this way some will fail quite soon. Damage is cumulative and the impedance of the output will gradually increase, maybe too slow for you to notice it without making measurements but it will occur.

On the other hand you might think we are all in a conspiracy to make you spend an extra \$0.01 on a resistor, funded by the resistor manufacturers. If so I want my cut now from all the unnecessary resistors I have encouraged beginners to use. On the other hand have you noticed that only beginners as this sort of question?

But you don't get it, it's not the problem of buying a resistor or not... I was just wondering "If PWM output is set to 66%, as if it was outputting 3.3v, why add a resistor, since it will drop voltage even more so the LEDs won't be at full brightness?"... But now (after re-reading entirely this topic) I think I understood :)

I will do what dhenry said in his last post, and use PWM's max value instead of trying to limit it.

Thank you :)

since it will drop voltage even more so the LEDs won't be at full brightness?

It just doesn't work that way. The brightness of an LED depends on it's current. Similarly, the voltage across an LED also depends on it's current, but not linearly as with a resistor. You must start by considering the LED current, not the voltage.

I will do what dhenry said in his last post, and use PWM's max value instead of trying to limit it.

Think of it this way, this technique also protects things in case the PWM output goes to 100% because of an error in the programming.

Don

I’ve used 2 diodes 1n4007 insthead the resistor ( series ) and it works great.

I can set pwm beetween tree values = 0 (off) 128 (it doesn’t give much light but readable) 255 (max).

The current consumption respectively 86-105-118 mA.

I hope this help

Steve

the voltage across an LED also depends on it’s current, but not linearly as with a resistor.

When you have some time, try to plot a LED’s V-I curve. You will be surprised. Particularly for high power LEDs.

I've used 2 diodes 1n4007 insthead the resistor ( series ) and it works great.

You don't understand the problem. This is a different way of reducing the maximum voltage applied to the backlight. The problem is that it is the current rating of the diode that we don't want to exceed.

Once again: if you to try to design a circuit to drive an LED with some specific voltage you are doomed to failure.

Don

:) Hi Don,

I'dont try to design a circuit to drive an LED with some specific voltage, my problem was turn off light (and mA needed).

:) in sainsmart shield with 2 diodes is solved.

Steve

Once again: if you to try to design a circuit to drive an LED with some specific voltage you are doomed to failure.

The story is actually far more complicated than that.

Some data:

For 1n4001 (Vishay, diode), If = 20ma @ Vfwd = 0.65v; If = 50ma @ Vfwd = 0.7v (delta Vfwd = 50mv); dynamic Rd = 50mv / 30ma = 1.6ohm. For CLA1B (Cree, LED), If = 20ma @ Vfwd = 3.05v; If = 22ma @ Vfwd = 3.10v (delta Vfwd = 50mv); dynamic Rd = 50mv / 2ma = 25ohm.

For the same change in Vfwd, the led's If increased much less than a diode's.

Contrary to conventional "wisdom", high power LEDs behave far more like a resistor than a diode.

psteve: The current consumption respectively 86-105-118 mA.

:astonished: How is that possible, if the PWM pin should not "give" more than 25mA ? And with LEDs OFF, it still use 86mA current? What I don't understand here... can you explain?

Thanks :)

Contrary to conventional "wisdom", high power LEDs behave far more like a resistor than a diode.

Is that what we are talking about here? I associate 'high power' LEDs with those that are becoming available to replace household incandescent bulbs etc. The LEDs being used in flat screen TVs could well fit into this category as well.

I would think that any LED backlight that is being driven by an output pin of the Arduino would be classified as low power, and it would behave much like any diode, not like a resistor.

Don