
Logic gates take binary inputs and produce a binary output. Combine them to compare values, perform arithmetic, or make decisions based on several conditions.
1. Physical characteristics
A circuit represents 0 and 1 using defined voltage ranges. The ranges depend on the logic family and power supply. Before connecting chips, check their input thresholds, output drive, supply voltage, and propagation delay. Leave no CMOS input floating. A truth table describes the logical result, while the datasheet describes the electrical behavior.

2. Types of logic gates
2.1. NOT
An inverter returns 1 for an input of 0, and 0 for an input of 1.

2.2–2.7. Two-input gates
| A | B | AND | OR | XOR | NAND | NOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
- AND is high only when both inputs are high.
- OR is high when at least one input is high.
- XOR is high when the two inputs differ.
- NAND inverts AND, and NOR inverts OR.
- XNOR is high when both inputs match.






3. Practical examples
3.1. An indicator with two sensors
Suppose A and B report activity. Use A AND B for a confirmed signal, A OR B for an early warning, A XOR B for a single active sensor, and A XNOR B to show agreement. An inverter lets you work with a sensor whose active output is low.
3.2. Fan control as a logic exercise
If T and P represent high temperature and high pressure, a simulated main fan can run when T OR P is true, while a backup turns on when T AND P is true. NOT (T OR P) is true only when both readings are normal. Compare the four input combinations.
3.3. An alarm with an exit mode
In the original diagram, an open door, window, or garage contact is represented by 0. Invert the inputs before combining them with OR. The automatic alarm requires the system to be armed, exit mode to be off, and at least one open contact. A panic button drives the final OR independently.

Alarm = Panic OR (Armed AND NOT ExitMode AND (NOT Window OR NOT Door OR NOT Garage))
4. Logic gates in microprocessors
Gates form adders, multiplexers, decoders, and other circuits. A half adder uses XOR for the sum and AND for the carry. Gates combined with state-holding circuits can also form registers. See how microprocessors use these building blocks and how data is represented in binary.
5. Worked exercises
5.1. Find the expression for a circuit
Trace an AND gate with inputs A and B. Feed its output and C into an OR gate. The output is (A AND B) OR C. With A=1, B=0, C=1, the output is 1.
5.2. Draw a circuit for an expression
For (A OR B) AND NOT C, draw an OR gate for A and B, invert C, then feed both results into an AND gate.
5.3. Quick check
Which gate outputs 1 only when both inputs are 0? Which gate detects disagreement?
NOR outputs 1 only when both inputs are 0. XOR detects disagreement.