Think about what happens when you get into a lift - the doors close, you press the button to say which floor you want, and the lift starts moving.
What happens if the doors close but you don't press a button to choose a floor? Nothing happens. The lift doesn't know which floor you want, so it stays where it is.
Alternatively, what happens if you are too quick to press the floor button, and press it before the doors have closed? Well, of course the lift doesn't start moving, that would be extremely dangerous. It will wait until the doors close.
The lift will only move if the door is closed AND you have pressed a floor button. The door has a sensor which produces an electrical signal when the door is closed. The floor button produces an electrical signal when you choose a floor. The control circuit inside the lift monitors both input signals, and only when they are BOTH on, it produces an output signal to drive the lift motor.
This type of circuit is called an AND gate.
An AND gate has two input signals and one output signal.
The two input signals can each be either on or off. When we describe logic gates we normally refer to these states as 0 or 1.
The state of the inputs controls the state of the output. The output value is 1 (on) if both inputs are 1, otherwise it is 0 (off). It is called an AND gate because the output will only be 1 if inputs A AND B are both one.
Here is the symbol for an AND gate. The inputs are labelled A and B, the output is labelled Q.
A truth table is a table which shows all possible combinations of inputs (A and B), and the resulting value of the output, Q. Here is the truth table for an AND gate, as you can see the output is only 1 if both inputs are 1.
Here is an interactive AND gate. Click on the inputs A and B to change their state, and see the output value Q.
Copyright (c) Axlesoft Ltd 2021