Power-up Nano PWM Pin

Hello everyone,
i'm working with a Nano and 5v white Leds, a simple set of 20 leds like the one you use for christmas.

The leds are on a PWM pin. At the full percentage (255) on the pwm the leds are less brighter than if i link it directly to the power source (without the nano).
What i guess is because the Arduino outputs gives 40 mA and maybe the power source instead (5v 1000mA the iphone one) gives all the 1000mA to the leds.
Is there a way to give more power to the leds on that pwm pin? So i cand have the same high brightness?

Thank you so much, i'm a little inexpert in electronics but i really like it.
Regards

Hello,

An Arduino output does not "give 40mA". It will give as much as is needed, but if that is over 40mA, it could be damaged. So you may have already damaged your Nano, perhaps only that output.

You need transistor. For example BC337. And a resistor, something around 200R to 1K. Connect the Arduino output to the transistor's base pin using the resistor. Connect the transistor's emitter pin to 0V. Connect it's collector pin to the negative wire from the leds. Connect the positive wire from the leds to 5V.

Paul

Hi Mario,
Paul is absolutely right, however for someone not experienced in electronics (or who doesnt speak Greek) that might be all Greek to you.
Attached are a couple of pictures that might shed more light on what was described.

Note that the image that contains the wiring diagram and the image of the transistor on the right is a different transistor than was suggested by Paul. So the values of the resistors used in that image may be different from what should be used with a BC337.

There are literally a gajillion transistors that will do this for you. The one you pick all depends on the total amount drawn by the LEDs and the total amount of juice you have to give it.

Note also that because the ends of the LED are not labeled + or - in the circuit diagram (it's the one with the two arrows shooting out of it - they indicate the light emitted), the resistor for an LED always goes on the positive side, or the long leg. I always think about that symbol this way. Either the arrow in the symbol shows the direction of the current (pos to neg), or, the cross bar that the arrow points to is a negative sign, and therefor the negative side.

Here's how this all works. A small amount of current comes out of the arduino pin and goes into the transistor. The transistor acts like a valve and lets a proportional amount of current shoot through it to the LED. The power from the arduino pin is never sent to the LED, it's just telling the transistor how much of the main 5V current to send through. As more and more current is sent through the arduino pin (based on your code) the more and more the transistor lets through.

To be truthful - that's not exactly whats happening. The Arduino is actually sending out pulses of current. On, Off, On, Off... But it does this very very fast. The longer the current is on between the "offs" the brighter the LED appears. The digital-out pins of the arduino only know how to be Full On or Full Off. They send out a square Wave. To get the illusion of brightness these pulses get longer or shorter, or are Modulated - hence Pulse Wave Modulation.

LED-driver.gif

LED-polarity.png

transitor.JPG

Dear Paul and ArdShark many thanks for your replies, very clear and helpful to let me understand better.
I need to buy the transistors so i will test it in the next days. I have 2 questions:

  1. About the transistor to choose, i see that the BC337 has different values about the maximum ampere (i see models like max 500mA, 800mA and so on..)
    In your post, ArdShark you say that the right transistor depends on the current that the leds needs, can you please help me to dimension and choose the right one?
    The cable has 25 leds.

  2. Applying transistor i will get only protection to the output? or i will have the leds brighter?

Thank you so much for your help i really appreciate it.
Mario

Mario, do you have multimeter? Use it to measure the current drawn by the led string when connected to the 1000mA supply. I guess it will be around 500mA.

Usually you still need a resistor after the transistor to protect the LEDs. However a store bought string may have these resistors in-line already.
The resistor is there to reduce the current to the LED's so they don't burn out. Yes the light will be less due to the "limiting" resistor, as it's called, but without one, that increase in brightness you get will only last for a very short time (sometimes milliseconds) before the LEDs will never light again.

Conversely (and I've seen this done which is why I mention it), thinking that you could use a lower amperage power supply to send a current closer to the theoretical current you would get using the larger PS and a limiting resister together, doesn't work either. Those LEDs will take as much juice as they can, and will attempt to pull too much power through your lower amperage power supply. If there is no fuse in the mix, you could burn out your power supply.

Think of the power supply amperage as the size of a pipe water is running through. The diameter determines how much water you can get out of that pipe. It doesn't mean you always have to open the valve full tilt - a little can always trickle down a big pipe. But it does mean if the device on the end needs more water than the pipe can deliver it will crumple the pipe in it's attempt to suck too much through it. That resistor acts as a check valve (or more accurately, a much smaller but stronger pipe that wont crumple ) to only let so much of the flow through regardless of how much the LEDs are capable of gulping down.

As for the transistor protecting the output (I think this is what you mean), the transistor is a low voltage/low current device (at least at the base leg) . With the right one, the arduino pin will safely send far less power than it's capable of to the transistor base, in a way, protecting the arduino pin or output. The transistor is our heavy lifter here. They are capable of funneling huge amounts of power between the emitter and the collector, even though a trifle is being sent to the base by the arduino. And generally the power being sent from emitter to collector never touches the pin of the arduino, so you are safe there. You have to pick one that is robust enough to handle the current of the LED string (between E and C) and sensitive enough that a range of voltages (0-5v for a standard arduino pin) will trigger the Base pin.

Ideally, in the transistor specs, the emitter/base voltage will be the same as the top voltage the arduino can put out. But this value must always be equal to or higher than the max voltage you are going to send out of the arduino pin, or you can burn out the transistor.
And the emitter/collector amperage spec must be higher than the expected max current the LED string will draw. The voltage of this spec must also be higher than the voltage you are using but this usually isn't an issue since the maximums here are usually up in the 30 to 50V (at least for the BC337 that Paul recommended).

One last consideration (that doesn't really apply here, but just FYI) is how fast the transistor is. Remember the output of the arduino is flashing on and off really really fast - you generally need an oscilloscope to see it its so fast. That transistor has to be able to keep up. It has to shut the power on and off in sync really fast so that the LED string looks like it's dimming and brightening as the time of the "on" cycle gets longer and shorter. The reason it usually doesn't matter for this kind of work is that the speed that the arduino can blink that output (with normal analogOut code) is usually far slower than most transistor's specs. But depending on your application, it can make a difference.

For the final spec on the transistor we really need to know how much current that string wants to draw and which arduino you have. A standard Uno will have a 0-5v output at the pin, one of the new small ones may use the new 3.2V output level. I've even got one here that outputs only 1V at each pin.

General run of the mill cheap LEDs tend to be 20ma each so that's where Paul got his 500 ma value from. 25LEDs x 20ma each = 500ma. Sometimes they are labeled; sometimes not.
Picking a transistor with a higher (or even much higher) Emitter/collector current is just fine.

Hi guys,
many thanks for your perfect replies.
I think today i can measure the current on the leds, i will keep you updated.
ArdShark,Paul your explanations are very detailed and i want to thank you for your patience. i have a basic electronic knowledge, just learn at school many years ago and is not all so fresh for me, but i'm keep going thanks for your help.

as soon i have the value i post it back here.

Hello,
i've got the measure of the current on the leds powered directly with 1000mA power supply.
The value is 0.68 A so i think a 800mA or 1000mA transistor should be good, is it correct?
I've getted a couple of it for testing online, and waiting to be here.

Thank you for the moment, i'll keep you updated about it.

Hi Paul and ardshark,
thank you for your replies, it seems to solve my problem about led intensity. Using the transistor the light is more intense.
Now i'm facing a problem mentioned in this topic

http://forum.arduino.cc/index.php?topic=403746.0

can you please help me facing this problem too?
I'll be very thankful to you.
my best regards
Mario