Consider this simple switchandlamp circuit. There is a power source, switch, and lamp.


The operation of this circuit can be represented in a table—a special kind of table known as a truth table.
Input State (the switch)  Output State (the lamp) 
Open  Off 
Closed  On 
The status of this simple series circuit can also be represented with a binary digit.
Substituting "0" for open/off and "1" for closed/on, the truth table looks even simpler:
Input  Output 
0  0 
1  1 
NOTE

The next set of figures shows the same kind of circuit, but with two switches connected in series with the battery and lamp. The following diagrams show the four possible states for the two switches (inputs A and B) and the reaction of the lamp (output Y)

Truth Table 

State 0: Both switches are open  the lamp is off. 

Truth Table 

State 1: Switch A is closed; B is open  the lamp is off. 

Truth Table 

State 2: Switch A is open; B is closed  the lamp is off. 

Truth Table 

State 3: Both switches are closed  the lamp is on. 
The lamp (Y) is ON, only when both of the input switches (A and B) are both ON. This example is technically known as a 2input AND logic function. The complete truth table for this 2input AND function looks like this:
A  B  Y 
0  0  0 
1  0  0 
0  1  0 
1  1  1 
Truth table for a 2input AND logic function.
This is called and AND function because the output is energized only when input A AND input B are energized. 
If you expand the circuit to include three switches in series (A, B, and
C), you have a 3input AND function. Notice in the following truth table
that the output Y is 1 only when all three inputs are 1s. (See the shaded
row on the truth table)


If you expand the circuit to include four switches in series (A, B, C, and D) you have a 4input AND function. Notice, again, that output Y is at logic 1 only when all four inputs are at 1. (See the shaded row on the truth table) 

The next set of figures shows a circuit consisting of a battery, lamp, and two switches that are connected in parallel with one another. The following diagrams show the four possible states for the two switches (inputs A and B) and the reaction of the lamp (output Y)

Truth Table 

State 0: Both switches are open  the lamp is off. 

Truth Table 

State 1: Switch A is closed; B is open  the lamp is on. 

Truth Table 

State 2: Switch A is open; B is closed  the lamp is on. 

Truth Table 

State 3: Both switches are closed  the lamp is on. 
The lamp (Y) is ON, when either or both input switches (A or B) are both ON. This example is technically known as a 2input OR logic function. The complete truth table for this 2input OR function looks like this:
A  B  Y 
0  0  0 
1  0  1 
0  1  1 
1  1  1 
Truth table for a 2input OR logic function.
This is called an OR function because the output is energized when input A OR input B (or both) are energized. 
If you expand the circuit to include three switches in parallel (A, B, and C), you have a 3input OR function. Notice in the following truth table that the output Y is 0 only when all three inputs are 0s. (See the shaded row on the truth table) 

If you expand the circuit to include four switches in parallel (A, B, C, and D) you have a 4input OR function. Notice, again, that output Y is at logic 0 only when all four inputs are at 0. (See the shaded row on the truth table) 

The digital world is more than isolated AND and OR functions. There at least several combinations of logic functions, and sometimes hundreds of them. Here are two examples of combinations of AND and OR logic functions.
Combination logic function Example 1 

In Example 1, input A is in series with the other two inputs. So as long as switch A is open (A = 0) output Y is fixed at 0, no matter what inputs B and C might be. Notice in the truth table that output Y is 0 whenever A = 0. When switch A is closed (Input A = 1), inputs B and C work together as a 2input OR function. So when A = 1, B and C affect the output as a 2input OR function.
Combination logic function Example 2 

In Example 2, the circuit behaves like a 2input AND function as C is open. When C is closed, the output is 1, no matter what inputs A and B are doing.