# Building NOT gate with transistor -- output remains always high

I'm following this tutorial to build a NOT-gate using a transistor (using slightly different parts).

The issue I'm seeing is the following: when no voltage is applied to the base of the transistor, then current flows, normally, through the path including the collector (as it should). However, when voltage is applied to the base, then current still flows through the path of the collector (should not). In other words, I always get high output, no matter what.

Question: I would like to find out is what I'm doing wrong, or what is wrong with my (still very limited) understanding of how the circuit should work.

Summary of what the tutorial says (in case the link dies later)

This is the circuit we are trying to build:

simulate this circuit – Schematic created using CircuitLab

This is how it is supposed to work (in my understanding):

• If SW is open, then current flows like this: +6V -> R1 -> LED1 -> GND
• If SW is closed, then current flows like this: +6V -> SW -> R2 -> B->E -> GND (In other words, no current flows through R1 and LED1).

Circuit I built

My circuit is slightly different, because I have different parts (in particular, I don't have any jumper cables yet), and also because I added some extra leds to try to "debug" the problem. I realize that these extra leds add more resistance (and previously I was using real resistance, where tutorial said to use a jumper cable), but I'm not sure if that matters or not.

This is the circuit (I think) I built:

simulate this circuit

And this is what is happening:

• When SW is open then only LED3 is lit up (as expected)
• When SW is closed then all three leds are lit up (LED1 and LED2 should be, but LED3 should not). In other words: the base has voltage (because LED1 is lit up), the current is flowing through B->E (because LED2 is lit up). However, the current is still flowing through +9V -> R3 -> R4 -> LED3 (because LED3 is lit up -- it shouldn't be).

(N.B.: I was seeing the same problem even before adding the extra "debugging" LED's, i.e. LED3 was always lit up, independently of the state of the switch.)

Pics of the board

Open switch:

Closed switch:

Research

This answer (to the related question) seems relevant.

In particular:

What you have done is connect the emitter to ground, and the collector to ground via a resistor. You have then applied a voltage to the base.

Yes, I did the same, with the exception that I connected the emitter to ground through a resistor (either the LED2 or the 220 Ω resistor I was using before due to the lack of jumper cable -- I'm not sure if that matters, though).

However in your case, the collector is not at a higher potential than the base, it is at a lower potential. [...] You now have current flowing from the base to the cathode, through the resistor to ground, thus the mysterious current flow is identified.

Could this be the reason in my case too? I don't know how to calculate the potential at the collector, and at the base, but I compared my circuit to the one of the tutorial, and these are my conclusions:

• The voltage of the battery is higher in my case (9 V vs 6 V), but I don't think it matters.
• The resistances are lower (440 (=220+220) Ω vs 1 kΩ), but they are the same on both branches. (I.e.: tutorial has 1 kΩ both on collector and base, I have 440 Ω both on collector and base).
• Also, I tried to increase the resistance for the collector, to 880 Ω (with two extra resistors), still the same result.

One more thing: I'm fairly sure that I connected the transistor the right way, but I tried the other way round too, just in case (same result).

• That's a well-written question. We can save you some of the pain of ASCII circuit schematics if you use the CircuitLab schematic button on the editor toolbar. When you've finished hit "Submit and Insert" and your editable circuit will be saved in your post without having a CircuitLab account. Double-click a component to edit its properties. Oct 7, 2020 at 11:36
• AACircuit? Haven't seen that in a while. Oct 7, 2020 at 11:45
• The BJT inverter must have the emitter terminal grounded, which is not the case in your schematic. Oct 8, 2020 at 7:02
• You can make jumper cables - just cut one of the legs off a resistor and use that. I think reading more about LEDs might also help - they don't work like resistors, and so you're bound to run into problems if you expect them to. LEDs are diodes - they conduct differently in each direction, and the amount they conduct doesn't change linearly with applied voltage. They tend to not conduct at all, until the voltage reaches a threshold, at which point they'll start conducting with very low resistance.
– LeoR
Oct 9, 2020 at 10:16

If SW is closed, then ... no current flows through R1 and LED1.

Not quite. Current always flows through R1, but when the transistor is switched on, all of the current flows through it, and since the collector voltage is now less than the LED's forward drop, no current flows through the LED.

When you inserted LED2 in the emitter lead of the transistor, you made it impossible for the transistor to pull its collector low enough to "short out" LED3. The emitter voltage is now equal to the forward drop of LED2, and the collector voltage is a few hundred mV above that.

If you take out LED2 and connect the emitter to ground again, the circuit will work as expected.

• For bonus points, connecting the emitter to ground through a resistor has much the same effect as using a LED - the path through the transistor no longer has a low enough resistance to "short" and prevent the signal LED from lighting. You could also put the LED's resistor on the LED's branch instead of the common path, which would change the relative resistance of the two paths even more. In any case, the critical point is that the circuit relies on the difference in resistance, which bears emphasizing. And of course, messing around with the transistor might have caused damage. Oct 9, 2020 at 8:05

Part 1:

If SW is open, then current flows like this: +6V -> R1 -> LED1 -> GND.

Correct.

If SW is closed, then current flows like this: +6V -> SW -> R2 -> B->E -> GND (In other words, no current flows through R1 and LED1).

Not quite right. Feeding current into the base will turn on the transistor. Current will flow through R1 but will be shunted around the LED through the transistor. If you turn on the transistor "hard enough" (enough base current) the collector-emitter voltage will drop to about 0.2 V and that's not enough to cause the LED to conduct significantly.

The problem is (I think) with your LED2. In the original tutorial, there is no LED in series with the transistor, which makes the circuit works like this:

• When SW is open, Q1 does not conduct, LED1 has to conduct as there is no other path.
• When SW is closed, Q1 starts to conduct and acts like a diode, and has a forward voltage of 0.2V. Your LED has a forward voltage of 1~3V(depending on the color). When two diode are in parallel and have different forward voltage, ONLY THE ONE WITH LOWER FORWARD VOLTAGE WILL CONDUCT, because the voltage change is not instaneous, but rises over time(although very quickly). When it gets to 0.2V, Q1 starts to conduct, which would maintain the voltage diff across Q1 at 0.2V, which means LED1 will never conduct.

Now, you've added a LED2 in series with Q1, which makes their combined forward voltage(yes diode in series gets combined) HIGHER THAN LED1, which means electrons will always go through LED1 regardless of Q1.

Here's how it works:

• SW is open, Q1 is not conducting. LED1 is the only path.
• SW is closed, Q1 can conduct, but the LED2 has the same Vf as LED1, which means LED2+Q1>LED1. So, when voltage rises to the Vf of LED1, (let's say 3V), LED1 starts to conduct, but it's not yet enough for Q1 and LED2 to conduct. As LED1 is conducting, it maintains the voltage difference at 3V, which means Q1 and LED2 will never be on.

TL;DR Remove LED2 and try again.

• Your description of voltage vs. time doesn't sound right. Diode current curves are current vs. voltage, not time. When the button isn't pressed, in the tutorial version the potential of Q1's collector relative to ground is about LED1's forward voltage. Pressing the button makes Q1 conduct, pulling the voltage lower than LED1's forward voltage, making it conduct near-zero current and stop glowing. (Because R1 drops all but the last 0.2 volts of the supply voltage.) So the important factor is Q1's forward voltage being much less than LED1's forward voltage, regardless of time. Oct 8, 2020 at 0:27
• Also note that the OP's photograph shows all 3 LEDs lit. This may just be from the base->emitter current through Q1. Even the small (maybe 0.2V) difference in forward voltages of LED3 vs. LED2+Q1 is probably enough that essentially all the current through R1 flows through LED3, no significant amount going through the collector of Q1. So your explanation of LED3 staying lit is right, but you forgot that LED2 is lit. Oct 8, 2020 at 0:31
• Right. Thanks for complementing my answer. I think you’re right about LED2 being lit from the base-emitter current. Oct 9, 2020 at 11:42

The problem you have relates to the voltage at the collector of Q1.

The purpose of Q1 is to short out LED3 when it's ON. As a consequence when LED2 is on, LED3 should be off and vice versa.

Now look at the voltages when Q1 is ON. LED2 will have a forward voltage of typically ~ 1.8V. Q1 will be saturated and have a Vce of ~ 0.2V (for a typical small-signal silicon transistor). These voltages are in series and up to 2.0V.

BUT, the voltage at Q1's collector is applied to LED3. 2V is enough to make LED3 conduct and as a result it never 'goes out'. In reality, some current is probably diverted from LED3 but not much.

Adding a small signal diode e.g. 1N4148 in series with LED3 increases the conduction voltage of the path including LED3 by ~ 0.7V. This is enough to stop LED3 illuminating when Q1 is on.

Removing LED2 would have a similar effect.

Try putting another LED or two in series with LED3, and see if that adjusts the voltages enough to make it work.

• Yes, but a good answer should explain why: that would raise the necessary forward voltage for that path through the circuit to conduct enough current to light up. Oct 9, 2020 at 10:29
• This answer is correct, but it doesn’t explain why Oct 9, 2020 at 14:27