• GirlsCodeIt

The Beginner's Guide To Logic Gates

By Spandana Bansod


Have you ever wondered what makes a computer work? Many will answer programming. Yes, it does help them work, but what is that, which really makes this magnificent device we call a computer intelligent enough to even process programs? There has to be something more tangible, something at its core. Well, if this is the question that has been bothering you since long, look no further than this article about logic gates, the answer to all your questions (well, maybe except where your socks are).

Understanding Boolean Values

While Boolean logic is a very vast field, today we’ll be going through just enough to help you understand how logic gates work, and why they do. So in boolean logic, ‘on’ is represented as 1, and ‘off’ as 0. This is done to help the software (parts you can’t touch but are probably what you think of when someone says the word ‘computer’, examples include google chrome, paint, google docs, minecraft, etc.) part of your computer understands the electronic signals from the hardware(the exact opposite of software, parts that are tangible, like your screen, mouse, keyboard, transistors, and the wires inside it) part of your computer.

Input and Output

Any information that is externally provided to a computer or circuit is called an input. For example, if you click the next button on your computer screen using your mouse, or enter numbers to add in the calculator, you are providing your computer input. Output is anything your computer or circuit gives out after it has processed your input. Following up on the previous examples, your computer may take you to the next screen after you’ve pressed the next button, and give you the sum of the numbers you entered to be added.

Common Logic Gates

So let’s put all we’ve learned to context now, and get started learning about some of the major logic gates.

The AND Gate

So let’s put all we’ve learned to context now, let’s get started learning about one of the major logic gates: the AND gate. It gives out the output 1, or on, only when both the inputs are on. Here’s what a truth table for the AND Gate would look like: (A truth table is table that tells you what you get in the output if you entered a certain set of inputs)

The OR Gate

The OR gate gives out the output ‘on’ when any one of the inputs is ‘on’, and also when both outputs are on, like the AND Gate. Here’s what a truth table for that would look like-


Also called the XOR Gate, the EXCLUSIVE OR Gate outputs ‘on’ only when either one of the inputs is ‘on’. If both of them are ‘on’, it’d output ‘off’ instead. Here’s what a truth table for that looks like:

The NOT Gate

The NOT Gate, unlike any of the other gates we have seen, takes in just one input. It then reverses the input, for example, if the input provided is ‘on’, it’d produce an ‘off’ as the output.

Here’s what the truth table for that looks like:

The NAND Gate

The NAND, or NOT-AND Gate, is a reversed AND Gate, just as the name implies. It gives out the output ‘off’ only when both of its inputs are ‘on’, and gives out the output ‘on’ otherwise. Here’s what the truth table looks like:

The NOR Gate

The NOR Gate is essentially a reversed OR Gate (notice the pattern with all the gates which have N as an added prefix?). It’s as if the results from the OR Gate were run through the NOT Gate. It would result in the output being ‘on’ only when none of the inputs are on. Here’s what the truth table would look like:

The XNOR Gate

As you’ve probably guessed from the pattern in the previous gates, the XNOR Gate is a reversed EXCLUSIVE OR Gate. it produces the output ‘off’ when just one of its inputs are ‘on’, and produces an ‘off’ otherwise. Here’s what the truth table would look like:

Terminology You Learned Today

While you may not have noticed it, you actually learned several new terms and concepts today. Let’s quickly go over them once to boost up your memory and help you retain it for longer.

  • Boolean Logic: A type of algebra revolving around the idea that everything is either true (1) or false (0)

  • Software: A program which runs on hardware

  • Hardware: The physical and tangible part of a computer

  • Input: Information externally provided to a computer, usually by human interaction

  • Output: Data generated by a computer, usually by processing input(s).

Do you have any questions, suggestions, or comments? Feel free to comment them below!

326 views0 comments

Related Posts

See All