I am very new to electronics field. Especially to the digital electronics.

I am trying to make an AND gate circuit using transistors, switches and LED. I have tried the below circuit:


simulate this circuit – Schematic created using CircuitLab

But there is a problem when simulating this circuit.

SW1     |     SW2     |     LED
OFF     |     OFF     |     OFF
OFF     |     ON      |     80%
ON      |     OFF     |     20%
ON      |     ON      |     100%

As you can see that above mentioned truth table is not AND Gate but it looks more like OR Gate. So, what is my mistake??

  • \$\begingroup\$ Put pull down resistors on the base of each transistor - perhaps about 10k. I also see no point for R3. \$\endgroup\$ – Peter Smith Jan 23 '17 at 7:44
  • \$\begingroup\$ @PeterSmith I have tried to do that but still I don't get the perfect output. I mean When SW1 and SW2 are off LED is OFF, When SW1 is ON and SW2 is OFF LED is OFF, But when SW1 is OFF and SW2 is ON LED is ON. \$\endgroup\$ – Vishal Jan 23 '17 at 7:57
  • 3
    \$\begingroup\$ You'll probably have better results with the LED "above" the transistors (on the collector of Q1), rather than driving it with an emitter follower. Also add a fairly strong pull down on their bases to ensure offness. In your current configuration, as soon as SW2 is on, some of Q2's base current will flow through the LED and illuminate it. \$\endgroup\$ – Colin Jan 23 '17 at 8:12

So, what is my mistake??

The mistake you have made is that current passing through SW2 will pass through the base and out of the emitter and then through the LED. A BJT has a base-emitter junction that is a forward biased diode.

If you used MOSFETs instead you wouldn't have this problem because the gate is insulated from the source.

  • \$\begingroup\$ After your answer, I have tried to use 2N7000 (MOSFET) instead of 2N2222 (BJT). But now no matter I have my switches ON or OFF, the LED glows. Why is it doing so?? \$\endgroup\$ – Vishal Jan 23 '17 at 16:09
  • \$\begingroup\$ Because you need pull down resistors on each gate to ground. When the switch opens the gate source voltage remains because of capacitance. \$\endgroup\$ – Andy aka Jan 23 '17 at 17:24
  • \$\begingroup\$ I have also tried that right now, but still it does not make any difference \$\endgroup\$ – Vishal Jan 23 '17 at 17:45
  • \$\begingroup\$ I should mention that, I have removed R3 and interchanged the position of R4 and LED. \$\endgroup\$ – Vishal Jan 23 '17 at 17:46
  • \$\begingroup\$ Maybe you have the mosfets incorrectly connected - it sounds like a source:drain reversal to me. Middle pin is gate of course but some fets are different to others. \$\endgroup\$ – Andy aka Jan 23 '17 at 17:53

The Forward biasing of Q2's BE junction when SW2 pressed, is causing the LED to glow.

You can try below,

  1. Relocate the diode D1 between +ve terminal of the power supply & collector of Q1 (i.e D1's Anode is connected to +9V & Cathode connected to Q1's collector).
  • 1
    \$\begingroup\$ The problem with this solution is that if more logic is being driven, rather than say an LED, then the output of the gate is inverted. \$\endgroup\$ – Colin Jan 23 '17 at 9:29

As colin__s already stated in the comments you can best move the led to the collector of the NPN transistor. When using an NPN transistor as a switch, you can best use it to pull-down current (connect the emitter to the lowest potential and the switched element to the collector).

Futhermore an LED usually can handle a maximum of 20mA, so I would increase the series resistor to 470 (so you get a lower current, (9V-1.6V)/470 = 15mA)). With the 300 ohm resistor your current would be >20mA.


simulate this circuit – Schematic created using CircuitLab

In this way the current flowing trough the base-emitter junction doesn't light the LED when only one of the switches is on.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.