A logic gate is an electronic device implementing a Boolean function. The logic gate performs a logical operation on one or more logic inputs and produces a single logic output. Logical gates are formed with MOSFET transistors and are the building blocks of all microcontrollers and digital electronics. It is important to have a basic understanding of the different logical functions such as the logical AND, OR, and INVERT.
The AND gate
The symbol for a two input AND gate is shown on the right and the truth table is shown below. The output is only true (value 1) if both the inputs are also true (value 1). If any one of the inputs is false (value 0) or if both the inputs is false (value 0) the output is false (value 0).
|A||B||A AND B|
The OR gate
The symbol for a two input OR gate is shown on the right and the truth table is shown below. The output is true (value 1) if anyone of the inputs are true (value 1). If both the inputs are false (value 0) then the output is also false ( value 0).
|A||B||A OR B|
The INVERTER gate
The symbol for an INVERTER gate is shown on the right and the truth table is shown below. The output of the INVERTER gate is always the opposite of the input. If the input is true (value 1) then the output will be false (value 0) and if the input is false (value 0) then the output will be true (value 1).
A Practical Example of the use of Logical Gates
Lets take an alarm system with a couple of magnetic switches on windows and doors in a house. We can define the status of a magnetic switch as false when it is closed and true when it is open. So if a magnetic switch is open (true) we want to sound the alarm and we want to do that for all the magnetic switches. By using a couple of OR gates we can combine all the inputs (magnetic switches) into one output status that will be true (value 1) if one or more of the inputs is true (one or more magnetic switches are open). So logical gates helps us to combine statuses and simplify solutions in the end. It is very easy to just look at one output and make a decision to sound the alarm or not instead of monitoring all the magnetic switches.