2N2222 LED switch for PIC output

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
I want to place LEDs on the outputs of a PIC to indicate when each output is high, but I want the LED to load the output as little as necessary. So, I thought I would use a 2N2222 to control each LED as shown in the attached schematic. With the green LED that I plan to use, and a 1k resistor, the current through the LED is 2.38mA, and the LED is bright enough for my purposes.

So, according to the "rule of thumb" (which I don't like, but don't have an alternative for), I would want .238mA of base current to Q1, which would calculate to 21k for R1. Sure enough, a 22k gives me .169mA, which I guess is close enough to the "rule of thumb." At that point, the current through the LED is 2.32mA, still bright enough for me.

But, if I make R1 51k, the current through the LED is unchanged, but the base current is down to .073mA. What's wrong with that, and why shouldn't I minimize the base current so long as the LED current remains at 2.3x mA?

Thanks.
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
At these low currents, it makes little or no difference, until you reach the gain of the transistor which should be a minimum of 75 for this transistor (at under 10mA from Phillips datasheet). The base current can be reduced to 1/75th of 2.32mA before there will be much difference, and that's for the lowest gain 2N2222s.
 

MrChips

Joined Oct 2, 2009
30,806
Your NPN transistor acts as a switch and is fully saturated.
I don't bother with transistor current gain in such situations.
I would put a resistor substitution box or variable resistor in place of R1 and adjust it until you get the performance you are seeking.
 

ErnieM

Joined Apr 24, 2011
8,377
A base current of 1/10th of the expected collector current is one of those rules of thumb you often hear about, and you can often ignore it as you see.

1/10 gives a margin of safety when very high currents are involved to keep the transistor well saturated. But with just a couple of miliamps in the collector there isn't a significant power loss anywhere.
 

BillO

Joined Nov 24, 2008
999
You have a lot of good answers already. I'd just like to add the that the 2N2222 is not the ideal transistor for such low currents. If you wanted to minimize your load on the MCU as much as possible consider a transistor like the 2N5232A which will provide a minimum gain of about 250 at 2.5ma and allow you to get away with a 430K base resistor. Or better still, use a little mosfet and have basically no load at all on your MCU I/O pin.
 
Top