# Integrating an AND gate into another logic gate

I am attempting to make a 4 bit computer with transistors. I've made a half-adder without too much trouble, but now I'm trying to incorporate the AND gate's output (the carry) into the next adder. This is the schematic I'm using for my AND gate:

simulate this circuit – Schematic created using CircuitLab

This isn't exactly how it looks (for one thing, mine has resistors), but this is basically it.

Using this, I know that if the LED is on, both switches are pressed. yay. But now I want to do something with that information. I'm at a loss for how to do this.

In a different gate where the output is after everything else in the gate (ie OR gate), I would just replace the LED with a wire that connects to the input of the next gate. I can't do that here because the output of the AND gate depends on the rest of the circuit.

Am I doing something wrong?

Thanks for the help.

If one of your resistors is in the collector of the top transistor, then you have created a nand gate. When you press both buttons the output of the top transisor will be low. You need to invert this to have an and gate.

• I'm sorry if I'm not following you, but in my circuit, if both buttons are pressed, electricity will flow through the LED. My question was about how to integrate this into another logic gate. Nov 13, 2016 at 22:39
• Your buttons put a high voltage on the inputs. This means you are defining 1V as logic 1. The collector of Q1 is the output of your gate. You have implemented 1 and 1 produces 0V. This is the nand function. The and function 1 and 1 should produce 1V. An inverter would change the 0V to 1V and give you an and gate. It you then put another and gate after his one, the 1V input would be like pressing one of your buttons. Nov 13, 2016 at 22:47
• Sorry if I'm not understanding, but if I implement 1 and 1, why is the voltage at the collector not 1V? Nov 13, 2016 at 22:56
• If it were the LED anode is at one volt and the Q1 collector was at 1V there would be zero volts across the LED. This means it would be off. Since you have created a nand gate Q1c is 0V and the LED is on. Nov 13, 2016 at 23:03

The transistors don't do any good. You should use the switches, themselves, in series, rather than transistors, to get the logic function you want. By choosing whether the switches are on the anode or cathode side of the LED/resistor (you do have a resistor, don't you?) you can get a NAND or AND function. BTW, the LED you chose has a typical forward ON voltage of 2 volts: you won't be able to use a 1 volt supply.

The circuit you showed us here is not a logic gate. It's something that creates light (or not) depending on the positions of switches. In other words, your circuit converts certain combinations of finger actions into some light level.

A logic gate takes potentials (voltage levels) as its inputs, and creates a potential as its output. It converts voltages to voltages.

The reason you don't know how to integrate your "not a gate" into another system of gates is that your circuit produces oranges when the rest of the circuit wants apples.

Here are some real logic gates (still not very good, though; see my last paragraph), taking input potentials and outputting a potential:

simulate this circuit – Schematic created using CircuitLab

It is true that we use input voltage to create currents in the input resistors, and we use current amplifiers (bipolar junction transistors) to control current through another resistor to derive an output, but those currents are not important to any "consumer" of the output or "supplier" of inputs. The consumers and suppliers do not care one little bit about how the thing works, only that this "gate" they are communicating with communicates using voltages.

A, B and C (input signals) are potentials. They might look like this:

As you would expect an inverter (NOT gate) to do, convert a high potential into low, and vice versa, the output of our inverter, F1, is a potential representing $$\F_1 = \overline{A} \$$. It looks like this:

The NOR and NAND outputs, $$\ F_2 = \overline{A+B+C} \$$ and $$\ F_3 = \overline{A \cdot B \cdot C} \$$ respectively look like this:

I repeat, all these signals are voltages. We can connect multiple units together input to output, since everything is speaking the same language, comparing apples to apples.

Here's how you might create an OR gate. We simply want to invert the output of a NOR gate. To do that, simply connect the output of a NOR gate to the input of an inverter (NOT gate):

simulate this circuit

Now all that is left is to consider how to get information from the real world into these logic systems, and how to get information out from the logic system into the real world. Since our logic systems deal with voltages, this is a process of conversion between physical phenomena such as "position" and "light", and our digital world of voltages.

This is how you can use a switch to measure "position", and create a high or low voltage depending on the switches state:

simulate this circuit

We can use transistors to switch current in an LED (or anything really, including relay coils or motors) on or off, depending on an input voltage. It looks similar to an inverter, but this time we do care about current, so we simply insert an LED in the transistor's collector current path:

simulate this circuit

Finally, you can put all these building blocks together any way you like. Let's build a system which with two switches, which illuminates an LED only when switch SW1 is closed and SW2 is open:

simulate this circuit

Now, this is not meant to be a good circuit. It works as advertised, but there are much better and simpler ways to achieve this behaviour. This is meant as an exercise in interfacing, not optimisation.

It also highlights a problem with the generalisations I have made in this answer. For example, simulate the above circuit and measure the voltage at point X. It's supposed to be a logic high, near 5V, but it's actually much lower due to the loading of R8 on the output of the NOR gate. That's another topic though. I will however show you an improved NOR gate, as a clue as to how loading issues were solved in DTL logic:

simulate this circuit