# How can I control PNP and NPN transistors together from one pin?

I'm trying to understand how it is possible to control a PNP and a NPN transistor simultaneously from one controlling pin.

My issue is that when the INPUT pin is left floating, the transistors drive each other and both go into conducting mode. When I try to pull the input pin up or down for those floating situations, the pull-up (or down) must be so powerful (few hundred ohms) that it causes high drain in the input pin, otherwise the transistors won't listen to this pulling of input pin.

simulate this circuit – Schematic created using CircuitLab

Please help me understand what I am doing wrong.

• For one thing, the base resistors could have a much higher value, like maybe 47k. Apr 30 at 21:33
• Sounds normal. What do you want to achieve by letting the input floating? Apr 30 at 21:33
• Thanks Dave, I thought and tried so, but even 3k@base dimmed LEDs strictly. Even using lowest possible hFE in my calculations I couldn't find any justifications for it. (My NPN is MPSA42 and PNP is SS9012 and 3.3v@VCC) Apr 30 at 22:05
• Dear Justme, It is a DC input power line that might be disconnected by user. So All I can do is to pull it for when it is disconnected and preferably a weak pull... Apr 30 at 22:07
• @AKTanara If so, then why have this circuit to begin with? Have the input drive one transistor/LED with weakly set default state, and use the output of the first transistor to drive the second. Apr 30 at 22:20

## 7 Answers

Have the input drive one transistor/LED with weakly set default state, and use the output of the first transistor to drive the second.

• Can you provide a schematic and simulation? I think I see what you mean, but it's better to show an actual circuit. May 1 at 1:17

You don't need such low resistances at the bases of the transistors; their current gain is high enough to respond to much, much lower current in the bases.

You can raise the values of the base resistors (R1, R3 below), and use a commensurately large pull-up or pull-down resistor (R5):

simulate this circuit – Schematic created using CircuitLab

• Thanks but in my working voltages with base resistors higher than 2K none of the transistors go into saturation mode that I need. May 1 at 20:07
• @AKTanara Then please, don't leave us hanging: edit the question to include the logic level voltages, and the supply voltage. And what exact transistors you're using, and are you sure they are not fake? May 1 at 22:26

Here is another way to perform the function you require. It's a basic push-pull emitter follower. I changed the LED resistors to 220 ohms to get 3 mA through the LEDs. If they need to be brighter, try 100 ohms.

simulate this circuit – Schematic created using CircuitLab

Unfortunately, there is a flaw in this circuit. With the input disconnected, there is still about 600 uA flowing in the LEDs, so they will both be on, but dim. This could be considered a "feature". And perhaps green, blue, or white LEDs might stay off.

Adding 1N4148 diodes in series with the LEDs reduces the no connection current to about 70 uA, but even with 100 ohm resistors for R2 and R3, ON current is only about 3 mA.

(edit) If the emitters are separated to drive D1 and D2 individually (I won't update the schematic), the circuit works properly, as illustrated here (off LED current is 33-43 uA):

(edit) Here is a circuit that lights each LED with about 6 mA, and with no input, there is only about 10 uA through the LEDs.

simulate this circuit

R1, R7, R8, and R9 bias the B-E junctions of the transistors to 0.53 V when there is no input, so they are both off. With either 3.3 V or 0 V applied, the 10k resistor provides about 100 uA to the base, which should be enough to to drive the LEDs with up to 10 mA with a beta of 100.

Here is another idea:

simulate this circuit

Well, that doesn't work very well at 3.3 V, but it would be OK for 5 V logic. Here are the plots:

• Thanks for the great extensive answer that taught me a lot. I'll try your first solution to see if its flaws are game changer for me or not. And about your second circuit I cannot understand what is the role of R8 and R9! Considering nature of NPN transistor that pulls its base down by itself and PNP that pulls its base up, why do we need those R8 & R9 pulling resistors? To my understanding these two resistors beside 10K resistors in series with bases will prevent most transistors from going to saturation mode... Am I right? May 1 at 20:35
• I'll edit my answer with an explanation, as well as maybe another possible circuit. May 1 at 20:40
• LOL, how you folks come up with these ideas? I'm going to try your 3rd solution ASAP. Also thanks for explanation you added for the second solution. My transistors (SS9012 & MPSA42) only dimmed LEDs with base resistors bigger than 2K. May 1 at 22:19
• @AKTanara LOL, how you folks come up with these ideas? The problem you have is so basic that anyone doing circuit-level EE professionally will be probably able to simulate it with a reasonable degree of accuracy using nothing but paper and pencil, a good refreshing drink of their preference, and a good chair, stranded on an uninhabited island. That's for both DC op point and AC small signal analysis that will be quite close to what Spice would put out. So, the ideas generally come from experience on working on much tougher problems :) May 1 at 22:54
• The third solution really won't work unless you use 5V logic. or have LEDs with a very low forward voltage, Also, it presents a constant 440 ohm load on the 3.3V supply. May 2 at 1:19

in my working voltages with base resistors higher than 2K none of the transistors go into saturation mode that I need.

I don't know what transistors you're using, but I don't believe for a second that they are not saturated at the couple mA of current you're flowing through them. After all, that's what you show in the question, even though I have an inkling that's not the case. See why providing too little information wastes your and our time?

The transistors would be considered saturated at V(CE) of about 0.1-0.2V, and I can guarantee that that's the case in your circuit as long as it's what you're showing.

So you're either misunderstanding what saturation is, or have some truly atrocious transistors, or are making a measurement mistake, or you're not telling us something - possibly some combination of those.

Higher collector current will be drawn by removing the LEDs, and even then lousiest of transistors I got in my junk box get saturated in this application.

I assume it's 3.3V logic and VCC. Suppose the transistor beta is 40. None of the modern transistors you buy would be that bad at the currents in your circuit.

They still saturate just fine with LEDs removed and 10k base resistors. With LEDs added, the saturation voltage is even lower, since only 30-50% of the current flows compared to when the LEDs were shorted out.

simulate this circuit – Schematic created using CircuitLab

You can simulate this circuit, click on SW1 to select it, then use space to flip back and forth between logic states on the input. The circuit works as you want it to.

With more reasonable transistor gains, it performs even better, letting you use larger base resistors.

simulate this circuit

Adding LEDs back into the circuit decreases the currents and lowers the saturation voltage even further. It's inconsequential either way.

simulate this circuit

The schematic was the simplest way to explain that I want a single input control two transistors of different type.

Absolutely not. Your circuit implies a lot about the load current and load behavior. A schematic is a graphical language to convey information. When having a specific schematic and no text to indicate otherwise, the schematic is all we got to work with to answer your question - it speaks in the words you didn't.

From your scattered comments I gather that you're driving a much heavier load than you're not telling us about. For that load, you will need either logic level mosfets, or two stages of transistors.

See, it is really important to actually say what you need, not to imply things with very little experience. You have asked a question and you will get answers exactly to that question you wrote, not to whatever you know but don't tell us. We cannot read your mind.

Had you asked about your real application, you'd have gotten relevant replies immediately, without having to go back-and-forth with comments and dosing the information in little drips.

I want a single input control two transistors of different type

Are sure that's what you need, or is that just a particular solution you have in mind, but not the actual need? If so, that woul be a case of an XY Problem.

Given the sparsity of information, you may as well just want one logic output to control two loads: one load active when the level is low, another load active when the level is high, and one chosen load active when the output floats - or perhaps no loads, essentially tri-level logic. It may come as a surprise, but that can be all done with transistors of just one type - so transistors of different types seem to be a spurious requirement that doesn't really capture what you need, just what you think the solution should be.

Now, if you knew what the solution is, you wouldn't be asking the question. Since you asked, you have to presume you don't know the solution, so don't presume one - but do tell us what you tried, after the problem was clearly stated in absentia of a particular solution that may turn out, after all, to be non-ideal, or just a kludge, or whatnot.

From what you're saying, let's see what current your actual loads need: you claim the transistors stay saturated with 1k base resistors, but nothing higher. Let's also say your criterion for saturation is $$\V_{CE} \le \frac{1}{2}V_{BE}\$$ - so, less than about 0.3V.

simulate this circuit

We can now run a parameter sweep for the value of the load resistance RL, looking at the collector current and voltage:

Saturation occurs with approximately $$\R_L\ge18\,\Omega\$$, and you seem to need about 250mA of load current. To get some factor of safety, we can assume 0.5A load current, and design for about 1A load current.

We note here that 200mA is the maximum collector current for the ubiquitous 2N3906/2N3904. So we need higher-rated transistors as the output stages, and a driver stage preceding them.

Now, it could be that you're using a medium-power transistor, with a lower gain, but higher collector current capacity. This doesn't change much, since it would need even more base current to get saturated for a given load, so the assumption of the load current is conservative and should cover your presumed needs.

So, we could have the following circuit:

simulate this circuit

It will easily switch a couple amps, with saturation voltage below 0.1V. The total dissipation in the circuit is below 0.5W.

The load on the GPIO pin is < ±0.1mA.

With the GPIO pin working a bit harder, we can get rid of one stage, and get rid of the separate pull-down resistor:

simulate this circuit

The GPIO current is 2mA in the high state, and nil in the low state.

Now, those circuits don't switch fast - it'll take several microseconds due to base charge due to saturation. If you need faster switching, additional desaturating transistors would be needed.

And, of course, we don't need two kinds of transistors. And we can get rid of one resistor as well :)

simulate this circuit

The GPIO current in the high state is 0.3mA, and nil in the low state.

Since all transistors saturate in this circuit, the switching is not very fast. We can do something about that. First, let's desaturate the 1st stage transistors by reconfiguring them as emitter followers:

simulate this circuit

Now we can add desaturating transistors that will bring the 2nd stage out of saturation on turn-off:

simulate this circuit

NOT1 and VCVS1 model a 3.3V inverter, such as 74LVC1G04.

This circuit switches in less than 1μs. Turn-on can be sped up by adding a small speed-up capacitor - like 20pF - in parallel with each of R1 and R2.

The GPIO load is 0.2mA during logic high state, and nil during logic low state.

If the load isn't particularly capacitive, the inverter becomes unnecessary:

simulate this circuit

• Although the OP @AKTanara has not confirmed it as a requirement, it seems that they wanted both LEDs to be off with the input disconnected. Without that specification, many simple implementations will work. But the mystery remains about the claim of needing such a high drive current. May 2 at 2:05
• Having the LEDs off when the input is disconnected is easy to accommodate. But OP wanted to use a pull-down on the input, and that doesn't do that. So I'll leave it as-is for now, and hopefully we'll hear more. May 2 at 2:08

# Separate control

## Basic idea

If we connect the transistors in an emitter follower configuration, their base-emitter voltages will be added to LED forward voltages and this will help solve the high impedance state problem. In this configuration, there are two separate emitter followers with a common input voltage and two separate LEDs.

simulate this circuit – Schematic created using CircuitLab

Below is such a "diamond solution" (with cross-coupled connections). As you can see, these are two separate emitter followers each driving its own LED. When Vin exceeds the total voltage drop Vbe + VLED across diodes, a current begins flowing and the corresponding LED lights up.

## Input LOW

simulate this circuit

## Input HIGH

simulate this circuit

## Input HI

simulate this circuit

## Varying Vin

simulate this circuit

# Common control

## Basic idea

If we stretch a string of two LEDs between supply rails, and the sum of their forward voltages is higher than the supply voltage, they will be off (the midpoint is free or connected to Vcc/2 = 1.65 V). When we change Vin up or down, a current begins flowing through the corresponding LED and it lights up.

In this implementation, the two emitter followers are combined into a complementary emitter follower and the two LEDs are combined into a voltage divider configuration.

## Input LOW

simulate this circuit

## Input HIGH

simulate this circuit

## Input HI

simulate this circuit

## Varying Vin

simulate this circuit

# Separate vs common control

The separate control has the advantage of adding a base-emitter voltage drop to the LED voltage drop. This advantage turns out to be essential at 3.3 V supply voltage. So here Vbe is something useful. A small disadvantage of the separate control is that it requires resistors for each LED.

The common control has the advantage of using only one resistor for both LEDs. But here the base-emitter voltage is not useful; it only decreases the LED current.

I have covered both configurations in detail in one of my papers.

• I "stole" your "diamond" solution as a simple modification to my first circuit. That is probably the simplest and most stable solution, and will work for higher voltages without modification. May 2 at 21:32
• @PStechPaul, Thanks for the response, I was expecting it. I will comment on it tomorrow as it is now 3 past midnight here. May 3 at 0:26
• @PStechPaul, I preferred to tell you some considerations in my answer so as not to get a long discussion here. It seems to me that both configurations have their place. Your first and my second schematic are almost equivalent; the difference is only one resistor. I would be happy to have more responsive people like you here to "melt the ice" and warm the atmosphere. Greetings, Cyril. May 3 at 9:20

Likely the computer cannot drive a 1k load. If the computer (or whatever) is on "INPUT" cannot pull up/down to with in 0.6 of the supply then both transistors are on. As staged before try 10k or something higher.

• A resistor from base to emitter would keep both transistors off with a floating input. Apr 30 at 21:57
• Most little transistors need a base current of 2mA to saturate and drive an LED with 20mA. If the computer signal is 2mA from 5V with a 0.6V loss then the base resistance is (5V - 0.6V)/2mA= 2.2k ohms. if the computer's supply is only 3.3V then the base resistance must be 1350 ohms. A few tested and selected transistors can manage a base resistor of double these values. Double the values again if the LEDs are dimmer with 10mA. Apr 30 at 22:09
• Thanks ronsimpson, As Audioguru mentioned I have tried different combination of base and pull resistors. Even 3k@base dimmed LEDs considerably... Apr 30 at 22:15
• Thanks PStechPaul, I be leave those pull resistors I have mentioned are doing exactly the same thing and all I'm trying to reach is a value that serves both low drain in input and good saturation @ transistors Apr 30 at 22:17

One approach to this would be adding diodes between the bases of the resistor, increasing the voltage drop. This would also need anti-leak resistors on the transistors:

Example in the fallstad circuit editor

This still allows 3 state control from the microcontroller (high-impedance, LOW, HIGH) while never lighting both leds at the same time

• The OP is using 3.3V logic and Vcc. May 1 at 19:29
• @Ferrybig Thanks. I have learned stuff from your answer. But for voltages more than 5v probably I will need more than 2 or 3 diodes in between. Am I right? May 1 at 20:23
• @AKTanara This solution depends on the voltage your board is using, (using 5V for example here, as no voltage was stated in your post) and works better with lower voltages as the knee of diodes is sharper. Instead of single diodes with an 0.7 voltage drop, you could also used leds (each color has a different voltage drop) or zener diodes May 1 at 20:44