Switching a 20mA LED with 4mA output of same voltage
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.