I connected two BJT NPN transistors and don't quite understand how it works

The following configuration is the output of a humidity detector made with one op-amp. The input of this circuit can be 3.3 V or 0 V. When 3.3 V, the red LED should turn on and when 0 V, the green LED should be on.

I connected the base of the second transistor to the collector terminal of the first one. I understand that having 3.3 V as input saturates the BJT and so the current flows from the battery V2 to ground, turning on the red LED, but why does the green one stay off during this time?

I would appreciate it if someone could explain to me how this circuit works.

• Please, pretty please, add a resistor between V1 + and T1 base Commented Jan 28, 2023 at 15:39

Why not using a pnp transistor as in the attached configuration

• Nice, albeit straightforward circuit solution - to drive a non-inverting and an inverting stage at the same time. One drawback is the rather wide overlap area. Maybe it would be better if put the diodes (with resistors) in emitters? Also interesting is the following question, "What would happen if you disconnect the input source?" Commented Jan 29, 2023 at 20:59
• This one worked too!! The thing is, my input is not 3.3V, it its like 2.36V so it's not enough voltage to turn the green LED on, but that's something i'm still trying to solve. Commented Jan 30, 2023 at 6:19

There should be some current-limiting resistor in series with the base. If you apply 3.3V the red LED and the transistor base will see a large and poorly defined (and possibly destructive) current. So let's put a 1K resistor in series with the base.

Case 1: Input is 0V. The transistor T1 is 'off', R1 supplies base current to T2 and the green LED has about 2-3V across it. The green LED current is poorly defined by will be limited by R8 and the transistor voltage drop.

Case 2: Input is 3.3V. T1 is 'on', the emitter will be at about 1.8 or 2V and the collector at about 0.1V higher so the base of T2 will be at about 1.9 to 2.1V. The emitter of T2 will be about 600mV less, or about 1.3 to 1.5V. That's not enough voltage to turn a green LED on (they require around 2 to 3V depending on the type, and the current).

Let's do a simulation with the available Circuitlab models:

simulate this circuit – Schematic created using CircuitLab

As you can see, it works, however the green LED is getting quite a bit of current- about 25mA (a result of the Circuitlab green LED model) and the red one a more reasonable 15mA.

This is not a great circuit (due to the poor control of LED current). It does allow a dual red/green led with common cathode to be used, but there are better ways.

Note that if you were to swap the red and green LEDs, the one driven by T2 (now the red one) may not completely turn off because red LEDs require less voltage to reach a given current and brightness. In such a case, the difference between forward voltage of the different colors works against you rather than for you.

Also note that T1 is likely saturated when the red LED is on, however T2 is never saturated even when the green LED is on, because it's an emitter-follower. That means it will have 0.6 or 0.7 volts across it (from collector to emitter) when it is on, whereas Q1 may have only tens of mV or 100mV across it if it's getting enough base current.

Edit: Here is one way to do it so that either LED can be either color and both transistors are saturated:

simulate this circuit

The input must be driven high or low. If it is left open then both LEDs will be somewhat 'on'.

• I have used your schematic as a base... if you don't mind? Commented Jan 28, 2023 at 11:28
• @Circuitfantasist not at all. Good to see it taken to improvements. Commented Jan 28, 2023 at 17:31
• Hello!! I had to swap the red and green LED's and as you said, it's not working. You also mentioned that there are better ways to build the red/green configuration, can you, please, mention some? Commented Jan 30, 2023 at 0:30
• Just to clarify, now I need the green one to turn on when the input is 3.3V and the red when 0V. Commented Jan 30, 2023 at 0:32

First, add one thing to your circuit: a series resistor on T1 base (1k ohm or so) to limit the base current when the input is above 2.2V or so. Otherwise the excessive base current will fry both T1 and the red LED.

Now, as to how it works:

• T1 base low: T1 off, T2 on (base pulled up by 100 ohm), Green LED on
• T1 base high, T1 on, T2 off (base pulled down by T1), Red LED on

The tricky thing is that each LED adds its own forward bias to the each NPN base voltage. That is:

• T1 turns on when base is 0.6V + 2.0V (Red LED forward voltage)
• T2 turns on when base is 0.6V + 3.0V (Green LED forward voltage)

So when T1 is on, T2 base is dragged low enough so that it is turned off. This is possible because the green LED adds an additional volt of ‘lift’ to T2 base turn-on voltage compared to T1, which has a red LED and a lower forward voltage.

When T1 is on then, its collector-emitter voltage (about 0.4V) plus the red LED forward drop (2.0V) is less than T2 base-emitter (0.6V) plus the green LED forward drop (3.0V). So T2 turns off.

Try it in a Falstad model here:

It works as described: input low, green LED on; input high (above 2.2V), red LED on.

There is still a transition zone where both LEDs are on (in the sim, this is when the input is between 1.7 and 2.2V.)

Exercise for the student: swap the two LEDs in the sim and see what happens. (prediction: T2 will never turn off.)

• Hahah thankss!! The simulation really helped me understand what was going on in there Commented Jan 29, 2023 at 19:41

Step 1: Trying to see the basic idea

In the OP's circuit diagram (I have used the @Spehro's schematic as a base), we see that the two LEDs are controlled by two transistor stages - inverting (Q1) and non-inverting (Q2). They are connected one after the other (cascaded) so the LEDs are in opposite states.

simulate this circuit – Schematic created using CircuitLab

Step 2: Discerning the basic idea

Fortunately, we notice something familiar (e.g., from TTL gates) in this straightforward circuit solution - when Q1 is on, it connects the diode D1 in parallel to a string of two diodes (Q2's base-emitter junction and D2). We know this is the well-known "current steering" phenomenon that states: If you connect two forward-biased diodes with different voltages VF in parallel and supply this network by a current source (voltage source and resistor in series), the current will flow through the diode with the lower VF.

simulate this circuit

For example, in the left part of the figure above, two Zener diodes with different threshold voltages - D1 (4.7 V) and D2 (5.1 V), are connected in parallel and supplied by a current source. As a result, the current is fully diverted (steered) through D1. Since the voltage across diodes is relatively constant, an almost "ideal" current source can be made by a voltage source and a resistor in series (in the right part of the figure).

Step 3: Simplifying the initial solution

So there is no need for the second transistor Q2 to control the green LED because the latter will turn off by itself when the red LED is connected in parallel with it. Since Q2 and R3 are not necessary, you can remove them and connect the green LED directly to the Q1's collector.

simulate this circuit

If the difference between the two VFs is not sufficient (as in the case), you can connect an ordinary Si diode in series to the green LED; it will act as the Q2's base-emitter junction in the initial circuit (it will artificially increase the forward voltage of the green LED).

simulate this circuit

Step 4: Improving the circuit

Now the red LED attracts our attention. Why is it put in the Q1's emitter? It raises the emitter voltage and greatly reduces the input voltage. So the red LED can be moved to the Q1's collector. This will lower the input threshold of the circuit. Of course, depending on the purpose of the circuit, this may or may not be desirable.

simulate this circuit

I have considered in detail similar devices based on this idea in one of my papers and one of my answers.

• I ask myself why "T2 and R8 are not necessary" (I suppose, you mean R3). If I understand the task of the circuit correctly, both LEDs must NOT be active at the same time. But - if we connect "the green LED directly to the T1's collector", this task cannot be fulfilled - both LEDS are "on" or "off" at the same time.
– LvW
Commented Jan 28, 2023 at 11:21
• Hi @LvW! Nice to see you here again. The two LEDs have different threshold voltages. For example, the red LED - 1.8 V; the green LED - 2.5 V. But some overlap does not hurt, even in most applications it is desirable. I am having trouble with the specific elements here because my schematics are conceptual and need generic elements... and I don't know exactly how to define them( for example, an LED with adjustable forward voltage drop). At a conceptual level, the details are distracting and prevent you from "seeing the forest for the trees". As with any tool, you win in one, you lose in another… Commented Jan 28, 2023 at 11:45
• Hi @Cicuit fantasist! I must admit that I am now slightly confused. Were the two circuits as shown under "simplification" part of your answer from the beginning? I took the answer to mean that the second LED should be in the collector path (between C and Vcc). If that was a mistake on my part, I'm sorry. It seems I am getting old....
– LvW
Commented Jan 28, 2023 at 14:26
• @LvW, The problem is not with you but rather with me because I made the circuit diagrams later. But you make me think of arranging my exposition better... Commented Jan 28, 2023 at 15:57
• @LvW, Inspired by your comment, I reworked my story into a more narrative form (as a 4-step building scenario). My ambition was for it to be more than a simple answer by revealing the philosophy of this particular circuit solution and showing the way to its refinement. With this I wanted to show how the inventor thinks when inventing and what the difference between ordinary constructive thinking and inventive thinking is. Commented Jan 28, 2023 at 19:22

For normal NPN transistors, Vce at satuaration is much smaller than Vbe. Thus, when T1 is on, Vce of T1 is smaller than Vbe of T2. T2 remains as off.

For example, for the 2N2222:

$$V_{CE(sat)}=0.3~\mathrm{V} @~(I_C=150~\mathrm{mA}, I_B=15~\mathrm{mA})$$ $$V_{BE}=0.6~\mathrm{V} @~(I_C=150~\mathrm{mA}, I_B=15~\mathrm{mA})$$

Some NPN transistors have an even lower saturation voltage like 0.05 V (NSS20501).