I want to drive an array of leds with a transistor, no more than 240mA the things is that im dimming them with PWM works fine with 5v PWM but im having problems with 3v3 uc because with full 3v the leds are not fully bright, I try to solve it using attaching the gate of another transistor to Vout like below but is not working. Any advice?enter image description here

By not Working im mean that PWM dimming is not working, LED's are always fully on with this approach

Its supposed to drive around 120mA per led array, this are the led datasheet

both transistors are BC337-40 (1A collector current, cant post datasheet link due to reputation)


simulate this circuit – Schematic created using CircuitLab

Wich one can be a suitable "new NMOS"?

  • 2
    \$\begingroup\$ Did you remember that the transistor in that configuration acts as an inverter? \$\endgroup\$ Mar 20, 2017 at 16:32
  • 1
    \$\begingroup\$ @IgnacioVazquez-Abrams, depends how the load is connected. If load is from Vout to ground, an equal problem is you're not going to deliver 240 mA through 1 kohm with a 5 V source. \$\endgroup\$
    – The Photon
    Mar 20, 2017 at 16:40
  • 1
    \$\begingroup\$ @Gaspar can you include the LEDs in your schematic? Are they driven from another transistor not shown in your circuit? Add that too. \$\endgroup\$
    – AngeloQ
    Mar 20, 2017 at 16:41
  • 2
    \$\begingroup\$ To the OP: May as well answer another question. Is the array of LEDs you mention specified for \$5\:\textrm{V}\$ operation? (Is it already designed to work properly using that supply voltage without adding anything to limit the current?) If so, can you link to the LED array device? Or are you designing that array, yourself? If so, can you specify the LED itself and how many? \$\endgroup\$
    – jonk
    Mar 20, 2017 at 16:45
  • 2
    \$\begingroup\$ The phrase "Not working" is "not helpful" when diagnosing a problem. \$\endgroup\$
    – Bort
    Mar 20, 2017 at 16:51

2 Answers 2


Thanks so much for your linked LED datasheet. (Nice specification sheet, by the way.) This makes it clear, as does your modified schematic now, that by "array" you mean "two" and that these are LED devices and not LED modules. This greatly improves the question.

It doesn't answer all questions. For example, the PWM rate you intend on using might be important in developing a practical design. But a practical LED intensity control doesn't need to be controlled at a finer resolution than 5 or 6 bits. And with a rep-rate of say \$100\:\textrm{Hz}\$, we still are on the order of \$150\:\mu\textrm{s}\$ periods and very little need for extremely sharp switching edges. So almost any modern parts used in modestly designed circuits is likely to work "well enough."

The answer with the least external parts is to find an NMOS which can easily switch your required current while at the same time driven from perhaps \$V_{GS}\le 3\:\textrm{V}\$. So something like this:


simulate this circuit – Schematic created using CircuitLab

I used two \$15\:\Omega\$ resistors here. (Use \$\frac{1}{2}\:\textrm{W}\$ size if you believe you won't ever short out the LED or else instead use \$2\:\textrm{W}\$ if you want to be absolutely safe even when the LED is shorted.) I think that's preferable. But that's not locked in. Other nearby values may work well for you.

The indicated NMOS is likely to itself drop significantly less than \$100\:\textrm{mV}\$, when driven from your \$3.3\:\textrm{V}\$ I/O pin and the I/O pin impedance is probably enough to avoid any worries about high frequency ringing on the gate. And the NTE4153 is about 40 cents in singles and it is in stock at Digikey.

But here's the problem. I used the typical case figure of \$3.15\:\textrm{V}\$ for the LED drop to specify the \$15\:\Omega\$ value. But the fact is, it could also be as little as \$2.8\:\textrm{V}\$ or as much as \$3.6\:\textrm{V}\$, unless you take the time to bin your devices or else buy them binned for you. (At the nominal current of \$120\:\textrm{mA}\$.) With the resistor values I gave, you may see anywhere from \$90\:\textrm{mA}\$ to \$145\:\textrm{mA}\$ through the individual LED. That's quite a range. So you may need to tailor the dropping resistor value together with the LED itself, if you plan on having them both appear approximately the same brightness. Or else bin the LEDs by hand or buy them pre-binned for you. (This isn't an uncommon problem and companies producing aircraft instrumentation, for example, go to some lengths to ensure that the apparent color and brightness of their entire LED display is well-matched.)

I also like to use BJTs (actually, I prefer using them.) But in that case, you usually have to consider the idea of the "rule of thumb" of using a current gain (\$\beta\$) of about 10. And given the current requirements you have, perhaps getting near to \$300\:\textrm{mA}\$, this implies a base current of \$30\:\textrm{mA}\$ and it's not likely you can achieve that.

There are two answers to that. One is to just assume (or get a BJT that allows you to assume) that the switching \$\beta\$ is more than 10. And this works. Most BJTs will switch well with \$\beta=30\$, or higher even, at these collector currents. In that case, you might decide that this is not a risky proposition and that perhaps delivering a base current \$\le 10\:\textrm{mA}\$ will be acceptable. In that case, you can get by with a single BJT. The other answer is to use two of them to get the necessary base current down, sufficiently.

The first case would look like:


simulate this circuit

In this case, I used a BJT that provides some nice curves and one of them exactly at \$I_C=300\:\textrm{mA}\$, providing some "typical" values for the collector-emitter voltage given the assumption about your base current drive. Roughly speaking, they say that \$V_{CE}\approx 140\:\textrm{mV}\$ in this case, which is probably acceptable. Power dissipation in the BC817 would be modest -- perhaps \$50\:\textrm{mW}\$ and almost certainly well under \$100\:\textrm{mW}\$ -- which is fine, too.

You could go to a second BJT, as I mentioned. But I won't add that schematic here unless you care about it.

The above schematic shows a base resistor value that discounts any I/O pin impedance. And besides that, you will have to ensure that your I/O pin is capable of at least \$10-12\:\textrm{mA}\$, too. In practice, I find that I/O pins often are capable of \$10-12\:\textrm{mA}\$ but that you may see as much as \$1\:\textrm{V}\$ voltage drop when doing that. So perhaps you should consider trying \$150\:\Omega\$ as another value to try out, as well. Or something nearby. (Don't take the value of \$220\:\Omega\$ as gospel.) The exact value will depend upon your I/O pin characteristics, too. (This fact is one more reason why an NMOS might instead be preferred.)

You can't just directly strap these LEDs together as you showed in your (newest) schematic; particularly, without any precision binning. They vary too much for that. The variability in the voltage drop of your LED devices (and it's substantial) can mean very different currents through them.

You could consider putting the two LEDs in series. Of course, their currents would be the same then. But this might require a voltage supply well above \$7.2\:\textrm{V}\$ and you haven't indicated a desire to go in that direction.

[Another approach might be some kind of buffered current mirror source pair where the current is set by an emitter follower current sink that you drive with your I/O pin. But that's also getting kind of crazy and adds still other problems to solve, including dissipation. There are also ICs which will do all this for you. So that's another way to go. And finally, you could consider separating the LEDs, using the same current control resistors for both, but calibrate the PWM % values differently for each LED. Again, that's also getting a bit crazy.]

So I just think the resistor idea is "good enough" to get by. If you really feel the need to further balance the currents, then you should either adjust the resistor values or else pre-bin your LEDs before pairing them up.

In case you want to go seriously insane on a circuit with a pair of LEDs and are willing to provide a \$+9\:\textrm{V}\$ supply rail instead of the \$+5\:\textrm{V}\$ rail, then here's a circuit that will provide current control and some improved (over BJT alone) thermal stability of the LED drive current (it should stay within 5% over quite a range of temps.)


simulate this circuit

I've even divided up the PNP power distribution into two cheap (less than a penny) transistors to keep their dissipation at or below about \$100\:\textrm{mW}\$ each. That should keep their temperatures in free air quite safe and reasonable and their collector currents well below absolute maximums.

Drive current from your I/O pin should be only about \$1\:\textrm{mA}\$, which almost any I/O pin can manage to do, quite well.

Note regarding added schematic showing 16 LEDs in two series strings:

A relatively minor problem with your schematic is that, in worst case bad luck, those 8 LEDs could add up to anywhere from \$22.4\: \textrm{V}\$ to \$28.8\: \textrm{V}\$. Unlikely in practice. But there's no guaranteed headroom here if all you use is \$28\: \textrm{V}\$ for the supply rail.

But that's the minor problem. The major problem comes from the possible worst case \$\Delta V=28.8\: \textrm{V}-22.4\: \textrm{V}=6.4\: \textrm{V}\$.

If you want to limit, let's say, current variation to \$\Delta I=20\:\textrm{mA}\$ over that range, then your resistor would need to be \$\frac{\Delta V}{\Delta I}=\frac{6.4\: \textrm{V}}{20\:\textrm{mA}}\approx 330 \:\Omega\$. But at a nominal current of \$120\:\textrm{mA}\$ in a series string, that resistor would drop close to \$40\:\textrm{V}\$, by itself. I'm sure that's not acceptable.

On the flip side, suppose you decided that you wanted to use a \$30\:\textrm{V}\$ rail. Then the dropping resistor would need to be \$\frac{30\:\textrm{V}-28.8\:\textrm{V}}{120\:\textrm{mA}}=10\:\Omega\$. But now what happens when you are unlucky enough to require only \$22.4\: \textrm{V}\$ for the series string? You'd get \$760\:\textrm{mA}\$. Of course, in practice that wouldn't happen because the voltage drops would increase as the current increased. (I don't have a model for these LEDs to make this answer quantitative about what probably would actually happen.) But the upshot is that your current would be "out of control." It's enough to know that.

So this means you can either increase your voltage rail to rather extreme heights in order to get some current control through the resistor, or else you can take a huge risk about current variations. Which would put a lot of pressure on you binning your LEDs, then.

You may really need to consider serious current control, instead.

I can't really offer a specific direction without knowing more about what you are willing to do. For example, are you willing to bin the LEDs before using them? Are you willing to buy them pre-binned? Are you committed to 8 LEDs in series? Or are you just floating random ideas, here and there, hoping "something works?" Are their ANY boundaries here?

You need to make some decisions, stick to them, and then figure out the implications for the circuit. Things are way too open still. You have some thoughts, though. And perhaps, you can now see why engineers are willingly paid money for thinking through all these issues and helping clients explore and then refine their options to a few workable ones (or to close off all the choices and stop the project, entirely.) Even for something as relatively simple as driving LEDs! (I'm just a hobbyist with zero electronics training. So I'm not pushing my own agenda here. I just recognize the value of experienced engineers.)

The last circuit (the insane one) I provided could be used to operate using any rail voltage you liked at or above perhaps \$30\:\textrm{V}\$ and you could do it still from your \$3.3\:\textrm{V}\$ I/O pin, just as I said before. And you would not need to bin the LEDs. However, you would probably need to replace the pair of PNP BJTs with a single, higher power dissipating one or else add another few to the pile there. The potential dissipation (worst case) could get to a watt, or even more depending on the rail you choose and the actual luck you get with a series string of LEDs, and that additional dissipation becomes a new concern, then.

  • \$\begingroup\$ Thanks a lot, really nice post so much helpful, I have one last doubt and then my understanding will be complete, as far as I understand as more lenght better distribution of color and brightness so for example the first aproach with the NT4153 would be more precise with more leds, just for example 8 leds in 2array and a supply of 28v. Now: 3.15v * 8 = 25.2v and 28v - 25.2 = 2.8v. this final result 2.8v should be distributed between 8 leds and the resistor of 117 Ohms I would need to replace NTE4153 for another wich support 28v of course. But is this approach now more accurate? New pic on post \$\endgroup\$ Mar 21, 2017 at 11:57
  • \$\begingroup\$ @GasparCatalan I'll write a note in my answer about this. It's more complicated than you imagine. \$\endgroup\$
    – jonk
    Mar 21, 2017 at 18:00
  • \$\begingroup\$ the truth is that I wanted to drive two leds correctly, now I know how to do it, I assumed that the same concept could work for more leds too, I see is not that easy. I use Leds a lot, have beein working with just normal 5mm but now I would like to move to the real deal but cant find good information, Im really grateful with the hand that you gave me. and yes im committed to 8 leds in series. increasing knowleadge step by step. \$\endgroup\$ Mar 22, 2017 at 18:49
  • \$\begingroup\$ @GasparCatalan With 8 LEDs you need current control circuitry. Using high voltage works, but wastes much power for the privilege. Lots of ways to do current control, but keep in mind issues such as changes due to increased and varying semiconductor die temperatures (not just the control circuit, but also the LEDs themselves.) Consider also accidental shorts and opens in the circuit. Simple circuits often take very little into account and are not very robust. While a good circuit may have more parts, these parts are often very cheap and the result may still may be very low cost to make. \$\endgroup\$
    – jonk
    Mar 22, 2017 at 19:23

Use a voltage regulator with an Enable

Use the enable to do the PWM.

It has a fixed output with many choices of output voltage
You can find the one closest to just over the forward voltage of the LEDs
Output voltages in white LED range: 2.8, 2.85, 2.9, 3, 3.1, 3.2, 3.3, 3.7, 4, 4.5

If you are powering a 5V LED strip there are plenty of 5V regulators with enabble.

enter image description here

Nice fast response enable to output

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.