The basis of building any logic circuit (even one as complex as a computer) comes down to logic gates. I will be discussing the 2 most basic logic gates today, an AND gate and an OR gate.

Logic gates are physical circuits that implements boolean functions, so to start let us look at the boolean AND and OR functions.

For all the examples below let us assume that we have 2 inputs: A and B, and that A and B both have 2 possible states: on or off, 1 or 0 in binary terms.

**AND Function**

An AND function requires both A and B to be in an “on” state to give a positive “on” result. (Just note the NAND function will give a positive “on” output when A and B are NOT both “on”. We will look at the NAND function and gate in detail at a later time).

Below is the state table for the AND function with inputs A and B as well as the resulting output:

A | B | Output |

0 (off) | 0 (off) | 0 (off) |

1 (on) | 0 (off) | 0 (off) |

0 (off) | 1 (on) | 0 (off) |

1 (on) | 1 (on) | 1 (on) |

**OR Function**

An OR function requires either A or B (or both) to be in an “on” state to give a positive “on” result. (Just note the NOR function requires neither A or B to be in an “on” state to give a positive “on” result. Additionally the XOR function will give a positive “on” output only when A or B are “on” but NOT when both are “on”. We will also look at the NOR and XOR functions and gates in detail at a later time).

Below is the state table for the OR function with inputs A and B as well as the resulting output:

A | B | Output |

0 (off) | 0 (off) | 0 (off) |

1 (on) | 0 (off) | 1 (on) |

0 (off) | 1 (on) | 1 (on) |

1 (on) | 1 (on) | 1 (on) |

Now let us examine the gate circuits. (I have constructed both gates on a Adafruit Perma-Proto board shown in the picture below).

**AND Gate:**

*Parts required:*

- 3 resistors (10k Ohm will do)
- 2 push buttons (input A and B)
- 2 BJT NPN transistors
- 1 LED (output)

So by pushing the buttons in accordance to the AND state table above the outputs can be recreated. Because the 2 transistors are placed in series the circuit can only be completed when both button A and B are pressed, and thus the AND function is implemented.

**OR Gate:**

*Parts required:*

- 3 resistors (1 x 10k Ohm and 2 x 660 Ohm resistors will do)
- 2 push buttons (input A and B)
- 2 BJT NPN transistors
- 1 LED (output)

So by pushing the buttons in accordance to the OR state table the corresponding outputs can be recreated. Because the 2 transistors are placed in parallel the circuit can be completed by pressing either the A or B button (or both). The circuit thus represents the OR function.

Just note the selection of resistor sizes are not cast in concrete, just pick a resistance high enough so your transistor does not get fried based on your power supply size (in my case a 9 Volt battery). I simply chose the resistors based on what I had available at the time.

Additionally if the role of the transistors in the circuit does not make sense to you please look at my earlier post (TRANSISTOR CRASH COURSE) that explains the functioning of transistors and their roles in circuits.