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

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

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 :slight_smile:

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

Thank you :slight_smile:

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

:slight_smile: 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).

:slight_smile: 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 :slight_smile:

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

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

I see people regularly drive over 70 mph in 55 mph zones. It seems to be working great for them as well (so far).

Don

Is that what we are talking about here?

I ran the data at 20ma If.

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.

Pick any such leds and show your data and we can have a chat.

Save you some time:

VLMx1300 (red, Vishay, LED), If = 20ma @ Vfwd = 1.95v; If = 30ma @ Vfwd = 2.0v (delta Vfwd = 50mv). delta Rd = 50mv / 10ma = 5ohm.

higher Rd for organge (50mv / 5ma) and lower for green.

None of this factors in the output resistance of the avr's (30 - 50ohm for example).

I may be mistaken but it appears to me that you are giving support to those who think that the LEDs that they are using with their Arduinos have a voltage rating (like a light bulb), and if they apply this voltage to their LED it will work properly.

Myself and other contributors such as Grumpy Mike and Liudr have, for several years, been giving advice on why this reasoning is incorrect an why they always need current limiting, usually in the form of a series current limiting resistor, when driving an LED.

Keep in mind that the target audience for the Arduino is not someone with an Engineering background and frequently not even someone with the slightest interest in electronics or microcontrollers. They are not concerned with the output resistance of an avr etc. and statements such as "For the same change in Vfwd, the led's If increased much less than a diode's" might just as well be written in Zorkonian. They are, however, interested in getting their LED to light up without damaging either the LED or their Arduino.

The bottom line is one can mess around with PWM, diodes, or some combination, but one should still use a series current limiting resistor with their LED.

Don

Myself and other contributors such as Grumpy Mike and Liudr have, for several years, been giving advice on why this reasoning is incorrect an why they always need current limiting, usually in the form of a series current limiting resistor, when driving an LED.

The length an advice has been given should be in no way shape or form supporting evidence for such advice's validity. Or we would still be living in dark ages thinking that the sun evolves around the earth.

Keep in mind that the target audience for the Arduino is not someone with an Engineering background...

Just because you think someone is "incapable" of understanding the truth doesn't justify your feeding them falsehood. You just need to figure out better ways to communicate the truth to them.

and I don't for a second buy the argument that the arduino community is 2nd rate when it comes to understanding electronics.

The bottom line is one can mess around with PWM, diodes, or some combination, but one should still use a series current limiting resistor with their LED.

The bottom line is that the laws of physics are the laws of physics, regardless of how long someone has been perpetuating anything to the contrary.

The bottom line is that the laws of physics are the laws of physics, regardless of how long someone has been perpetuating anything to the contrary.

And you dear Henry dear Henry talk utter rubbish.
It is time you stopped.