# uC output to control bipolar transistor switching

Discussion in 'Embedded Systems and Microcontrollers' started by ke5nnt, Oct 9, 2009.

1. ### ke5nnt Thread Starter Active Member

Mar 1, 2009
384
15
I would like to use the state of an output pin to control switching of a transistor so that I can turn on/off 6 LEDs. I know that 6 leds is too much for an output, but shouldn't be for a transistor.

Using an NPN transistor, like N3904 for example (I have them on hand), how would I go about figuring out how to do it? My biggest problem is in figuring out how to stay within device limits. For instance, I'm not sure how much voltage/current is coming out of the uC output pin and going to base, and if I need a resistor between the two.

Also, from say a 9 or 12V + power source through the led's in series to collector, I'm almost certain a resistor would be required there. But then I face the problem that if an LED Vf is 2.0 volts, that means each one eating off 2 volts I'd be left with 0 volts if using 12V power supply, so can I break the LEDs up into 2 groups of 3 but still control them off of one transistor connected to 1 uC output pin?

Dealing with certain electrical characteristics confuses me, and I don't know much about the operating/wiring characteristics of transistors yet. Even after looking at the datasheet of the N3904 and reading the AAC book on bipolar transistors. Ugh!

2. ### russ_hensel Well-Known Member

Jan 11, 2009
818
47
How to do this is all over the internet. Just Google around a bit.

3. ### Markd77 Senior Member

Sep 7, 2009
2,803
594
You should be fine. The HFE of the transistor is the important number and is how much the current going into the base is multipled by. If HFE is 100 (a fairly typical value) then 100mA through the LED network would only mean 1mA out from the pin. Go for 2 parallel sets of 3 series LEDs and work out the resistor required.

4. ### ke5nnt Thread Starter Active Member

Mar 1, 2009
384
15
Thought I'd post a quick update to give closure to this thread.

I got it all worked out, problem solved.