# Switching a 20mA LED with 4mA output of same voltage

I have a USB controller card with output pins of 3.3V and a maximum current draw of 4mA per pin, and I'm trying to use it to control 3.3V 20mA LED's.

I figured I'd need to use probably an NPN transistor and have seen that they generally seem to look like this:

simulate this circuit – Schematic created using CircuitLab

However there's many things I'm unsure about

• Will this need resistors R1/R2/R3? If so, what values?
• The output card's dedicated +3.3V pin will likely not be able to supply the required current either. Can the collector be connected to an external power source or could this cause problems as the pin is powered by a computer's USB port?

• Why do you want 20mA? 3-4mA is often more than bright enough for an indicator LED. May 6, 2018 at 1:37

I have a USB controller card with output pins of 3.3 V and a maximum current draw of 4 mA per pin, and I'm trying to use it to control 3.3 V, 20 mA LEDs.

This is a little awkward. For a simple circuit with a current limiting resistor we generally need some voltage headroom to allow for the voltage drop across the current limiting resistor and the transistor switch. In your case the nominal forward voltage, VF, of the LED is the same as your supply voltage so we have no headroom to play with.

It may seem that this is actually an ideal situation but the VF is a nominal value and will vary from device to device due to production spread.

Figure 1. Variations in LED I-V curves. Source: Variations in VF and "binning" where I expand on this further.

I figured I'd need to use probably an NPN transistor and have seen that they generally seem to look like this: [See question.]

The arrangement you have drawn is more like a voltage follower. It is unsuitable for your design as there will be a 0.6 V drop in voltage between the base and the emitter and other voltage drops associated with the various resistors. The LED voltage is likely to be inadequate.

Figure 2. A typical NPN transistor switch. Source: Driving LEDs on higher voltage.

The usual method of driving an LED using an NPN transistor is shown in Figure 2. This has the advantage that it can switch LEDs driven from a different power rail than the microcontroller. See the linked article for more details.

Can the collector be connected to an external power source or could this cause problems as the pin is powered by a computer's USB port?

USB power is 5 V so this could be the solution to your problem. Using the schematic of Figure 2, your micro is running from a 3.3 V regulated supply but you have 5 V available for the LED. Connect the 5 V to the point marked VSS.

As Spehro says, you probably don't need 20mA, and you can drive the LED directly. Many port pins can sink more current. i.e connect led to 3.3V and turn it on, with port pin LOW.

All you need is this - there is not point in the other Rs. But use the simulator, and learn to measure current, and try different LED colors (hint xxEE is red, xxGE is green) and supply voltage.

simulate this circuit – Schematic created using CircuitLab

Prove it to yourself

• S/he'll have difficulty in proving that this will work. If the controller output pin is at 3.3 V then the best you can get at the emitter of Q1 will be 3.3 - 0.64 = 2.7 V and that's before we add in the 100 $\Omega$ resistor. The LED probably won't light as it's rated $V_F$ is 3.3 V. May 6, 2018 at 12:12
• Aw shit, my LED's must've aged in the drawer again. They're only 1.8V - no wonder the light is all red color now! May 6, 2018 at 20:44
• Sorry, I don't appreciate your crude response. Bye. May 6, 2018 at 20:45