Logic Gates Crash Course: Learn AND, OR, XOR, NOT & Build Circuits

Logic Gates Crash Course: Learn AND, OR, XOR, NOT & Build Circuits

Hey there! In this video, I’m diving into the world of logic gates – AND, OR, XOR, and NOT. We’ll break down how each gate works, draw them in ANSI style, and rig up a circuit to see how they turn inputs into logical outputs. I’ll walk you through truth tables and show you how to chain gates for cool results, all while keeping it real and relatable. Whether you’re new to digital logic or just want a refresher, this is for you. Got questions? Drop a comment! Subscribe to join the crew, and scan the QR code to check out my site for more tutorials. Let’s geek out together!

Introduction to Logic Gates 00:00:00
Overview of AND Gate 00:00:47
Overview of OR Gate 00:01:07
Overview of XOR Gate 00:01:24
Overview of NOT Gate 00:01:49
Drawing AND Gate 00:02:14
Drawing OR Gate 00:03:07
Drawing XOR Gate 00:04:12
Drawing NOT Gate 00:05:31
Building a Circuit 00:06:04
Combining Gates 00:07:21
Testing with All Zeros 00:09:56
Testing with All Ones 00:11:23
Testing with Random Inputs 00:12:32
Introduction to Truth Tables 00:15:00
Creating Truth Tables 00:16:03
Analyzing Circuit with Truth Tables 00:18:50
Hierarchical Truth Table Approach 00:20:04
Final Circuit Analysis 00:26:36
Conclusion and Call to Action 00:29:15

Thanks for watching!

Find us on other social media here:

  • https://www.NeuralLantern.com/social

Please help support us!

  • Subscribing + Sharing on Social Media
  • Leaving a comment or suggestion
  • Subscribing to our Blog
  • Watching the main “pinned” video of this channel for offers and extras

Okay, hey everybody! In this video I’m going to talk about logic gates. I’m going to show you

AND, OR, XOR, and NOT. We’re going to draw them in a diagram style and we’re going to rig up a

bunch against each other and see if we can figure out how they would process some input data into

you know some logical output.

Okay so for starters let’s just go over what the gates look like. If you don’t know how these gates

don’t know how these gates work check my previous videos because I’ve explained them there. Here I’m

just going to sort of try to draw them and make a little big a little circuit area that we can play

with. Okay so AND. Okay you know what you want me to I’ll just do a quick recap. The AND gate just

means that both bits have to be a 1 in order for a 1 2 output so if we do a 0 and a 0 and a 1 and

sorry one and a zero and a one and a one then only this one is going to end up being a one

everything else is going to be a zero for the logical or it’s going to be if we do zero zero

zero one one zero and one one and if this is too fast and confusing for you see my other videos

but basically it’s going to be a one for those three because if either of those bits are a one

then the output is going to be a one and the only place it’ll be a zero is when both of the bits are

Let’s look at XOR. So XOR is

Basically and it’s an OR except this one position right here where both bits are a one that would end up being a zero

So for XOR 0 0 0 1 1 0 1 1

It’s going to be a 0 and

Then a 1 and then a 1 and then a 0 so it’s just a little bit different from OR and then not just inverts the bits

so

bit at a time and it’s just a zero becomes a one and a one becomes a zero and that’s pretty much it

okay so maybe I should put not right here just to just to emphasize that I’m talking about not

okay I’m definitely not not talking about not sorry so let’s do uh let’s draw a logical or a

bitwise and gate it’s basically just kind of like this and then there’s a little flat ridge at the

end of it and it takes two inputs there are many different styles to draw these kinds of gates but

i’m going to use the ansi style i think for the most part so just keep in mind you know you can

draw these in many different ways it’s going to take two inputs imagine this is a little circuit

right here and it’s going to give you one output so if you imagine what we talked about before

we could send it two different bits and it will produce the output for us so if we give it a zero

for us. If we give it a 0 and a 1, it’s still going to output a 0. If we give it a 1 and a 0,

still a 0. If we give it a 1 and a 1, then finally it’ll actually give us a 1.

Okay, so that’s just the way that gate looks. And now I’m going to draw the next one.

Let’s draw the OR. So maybe I’ll put OR here. Whoops. Oh, I got to do that. OR. So the OR gate

kind of looks like the AND gate at least in the style that I’m drawing except the

the flat ridges is more curved like this so you know an AND gate I’ll draw it in

red just to remind you that this is not what we’re doing right now it’s you know

flat right where’s the OR gate it has a curve it’s like a crescent moon kind of

it still takes two inputs so I’m gonna do an input here and an input here and

it still has one output and so if we’re just gonna give it a zero and a zero it’s

give it a zero and a zero it’s going to output zero for us if we give it a zero

and a one it’s going to output a one if we give it a one and a zero it’ll still

output a one if we give it a one and a one it’ll still output a one okay that

was pretty easy let’s look at exclusive or so XOR XOR the XOR gate looks like

like the ore gate so i’m going to start by trying to draw an ore gate as best i can

which is not good oh god let me start over on that one let me try one more time and then i’ll just

give up okay do this and then i’ll say okay that was good enough and then it has another line right

here the line is supposed to be parallel to the uh the crescent moon you know the curved side but

and that way it sort of looks like the inputs are passing through

like the first line before they touch the actual ridge.

So that’s an exclusive or it also outputs one bit.

So just practicing, we’ll give it two zeros.

It’s going to output a zero because there’s no or involved in two zeros

or I guess there’s no orness to the two zeros.

If we give it a zero and a one, then that’s going to output a one

one input is a one if we give it a one and a zero same thing looks good because

one input was a one but then once we get to two inputs then it’s going to output

a zero because the exclusive or demands that only one of the bits is a one and

actually exactly one of the bits is a one to produce a one okay so then the

next thing that I can show you is a knot gate it’s sort of like a little triangle

are different drawing styles it takes only one input and then there’s like a little circle up

here on top and then it outputs at the top and so if we give it a zero it’s going to output a one

i guess i could draw it a second time since there’s only you know two things we can we can input to it

it’s going to give us a zero if we inputted a one into it so it just reverts it’s an inverter

helps you understand the basics of these types of gates. Now I’m going to try to make a bunch of

them see if I can come up with something interesting on the fly. I had problems with

the drawing system on my other computer so I didn’t really prepare an example. Hopefully this

is good you never know. I’m just going to draw an AND gate here and I’ll say that it takes two

inputs because that’s what it does and then right next to it maybe I’ll do an exclusive OR so I’ll

like an OR gate here, and then I’ll do the exclusive OR part of it, and I’ll give it

two inputs because that’s what they take.

And then next to that, maybe I’ll just do a regular OR.

We’ll say OR, just like that.

Oh, that’s awful.

Try one more time.

Just do this, and then say this.

Okay, that’s acceptable, sort of.

We’ll do two more inputs there.

And what else can I do?

What else can I do?

Should I do another exclusive or or an and?

What do you think?

Vote.

Just kidding.

I’m going to do an and right here.

So I’m kind of repeating one of the gates.

Let’s see.

And or X or not.

Yeah, that’s all I wanted to talk about.

Okay, so now we can combine them because remember these have an output.

But if we sort of use the outputs of two of the gates as input for another gate,

then we can you can we can sort of like chain uh our circuits to make something a little bit more

interesting so maybe here i’ll do an and i’ll say this is an and gate oh god that’s awful

one more time okay my text-to-speech engine who i’ve given the personality of mary poppins

is telling me that a door is open so i’ve got to close the door after this video anyway

video anyway um yeah I have like an LLM server uh in the other room and so now my home assistant

is a little bit smarter and sometimes she messes with me that’s a story for another video

so I’m combining the output of both of those gates and sticking them into an and

and then I can do the same thing here I think I drew those I think I drew it like way too high

I’m gonna run out of room let me try one more time put that there we’ll do an and gate

gate like that and then I’ll just maybe curve the wires so it seems like uh it makes more sense okay

and then maybe over here I’ll do uh I don’t know maybe this should be an or I’ll do an or gate

like that and then the inputs from the other ones go into the or gate

then these two can combine to one more so maybe I’ll do exclusive or

or I guess I’ll just put an or gate here and then I will that’s not that’s not

curvy enough is it I like my Alex might I like my XOR gates nice and curvy so

we’ll do this and then I’ll put another line under it and then we’ll connect

these two so we’ll do this okay so then finally we have like one bit that’s

one bit that’s going to come out at the top let’s use the knot gate might as well so i’m going to

connect this to a knot gate and put a little circle on top of it and then it will give us our

final output and maybe i’ll stick it here in green or something like that okay so there’s lots of

different uh input output combinations we could use uh let’s see for every input we have that’s

one bit so one two three four five six seven eight that’s eight bits that means i could draw out

256 possible input combinations, which I’m definitely not going to do in this video.

But let’s just do some random stuff.

Let’s start off with zeros just for fun.

So we’ll do a bunch of zeros here.

So if you sort of look at this diagram, we go, all right, what was that?

This and here, there’s two zeros.

It’s going to produce a one.

So I’m just going to put a one right here to remind me that a one is going to be the

output of that gate.

the OR gate here is going to also output a what am I doing why did I put a one a zero because zero

and zero is zero and then zero or zero is also zero so this is going to output a zero and then

this exclusive OR is also going to output a zero and then the end is zero so I just have zeros at

the next level then we look at the inputs here to this and that’s obviously going to be zero and

then we look at the OR here that’s obviously going to be zero and then those two go into the gate

that’s a little bit higher and it’s going to output a zero because exclusive

or needs at least, you know, it needs exactly one, uh, one.

So it kind of feels like it’s going to be a zero for the output, right?

Uh, you’d be wrong if you thought that because the knot is going to invert it.

The knot is going to take that zero and flip it to a one.

So if we do all zeros, the answer is actually going to be a one.

Okay.

Let’s reset this and try again.

So I’m going to just get rid of these greens here.

and then I’m going to do, maybe I should write the inputs in red so they’re more fun,

so they don’t feel like they’re blending too much in with the actual diagram.

Okay, so now I’m going to, let’s try all ones. Let’s see what happens if we do all ones.

So I’m going to do ones on every input. One, one, one, one, one, one, one. And so

if we look at this AND gate, it’s going to output a one because, well, a one and one is a one.

one is a one the or gate same thing because a one or one is a one and then do the same thing down

here for this and and then the exclusive or that’s going to be a zero because it wants exactly one

bit to be a one not both so it’s a little bit more interesting and then we go up one level this and

gate is going to output a zero because it wanted both of those uh inputs to be a one for it to

output a one and then for the or it’s also going to output a well it’s going to output a one again

both of those are ones and then if we look at the exclusive or oh that’s going to output a one this

time because exactly one of the inputs is a one then the not is going to invert it so the final

answer is going to be zero for this whole giant thing i want to say make sense and wait for

questions but i guess i can’t so let’s try another example i’m going to do maybe two examples with

totally random numbers and then i’m going to show you how to write a truth table that might help you

might help you work this out on paper or like a like a notepad if you don’t really want to draw

so let’s see um uh i guess i’m gonna like maybe take some of these and turn these into zeros

let’s see get rid of that make that a zero maybe like i don’t know i feel like i’m not random

enough okay one zero and then like a maybe like a zero here how about like a one there and a zero

How about like a one there and a zero there?

Just one, zero, one, zero, oh, one, oh, one.

That’s too much of a pattern.

Let me do, let me do a one, oh here, or a one and a one.

Okay.

That feels more random to me.

So looking at the AND gate, that’s going to output a zero.

The OR gate is going to output a one.

The exclusive OR is going to output a zero.

The AND is going to output a zero.

So we just got a one right there.

So this AND is going to output a zero again.

This OR is going to output a one.

And then the exclusive OR, it’s got enough to output a one.

it’s got enough to output a one so that’s nice and then its final output is going to be

a zero because we had to not that one nice okay let’s just i don’t know change a couple random

bits i’m going to change this well let me erase first and then i’m going to start changing random

bits i don’t even remember what that last bit was anymore i’m going to pretend it was a one

and then i’m going to change it to a zero and then i’m going to change this zero to a one

change this one to a zero and then I’ll change this this zero to a one not like exactly random

it’s human random sort of so let’s look at this the and is going to output a one and the exclusive

or is going to do a one and then the or is going to do a one and then the and is going to do zero

one and one zero okay I think I did it right so the or is going to do a one and then I think

what’s happening is I gotta adjust my penmanship style I still have to like lift up sooner so it

doesn’t change colors so then the end it’s going to output a one and then this exclusive or it’s

going to output a zero because it wants only one bit one input to be a one and then the not is

Okay, let’s look at the idea of using a truth table to make this a little bit easier to

solve if you’re just kind of doing this without drawing.

So I’m not going to clear this just yet.

I might have to clear it in a second.

The first thing that you should do when you’re making a truth table is, you know, I mean,

I guess you can style this however you want, but you kind of have to think of this hierarchically.

Like what’s the easiest thing to do?

You don’t want to start computing the thing at the very top because that depends on a

lot of other stuff that’s at the bottom.

So instead I’m going to look at the very bottom row of inputs because they’re the easiest to calculate.

So I’m going to do and, I’m going to say something and something.

I guess I’m just going to put and by itself.

Maybe I’ll put one for input.

So for the inputs, I’ll just do the bits here.

0 1 1 no okay let’s just use two inputs only because we’re looking at the lowest level here

yeah and we’ll make maybe like a separate row or separate table for that so we just have two

inputs per gate on the bottom row and so for the end it’s going to be a one right then for the 0 1

should just do this in numeric order. I’ll just do every possible combo because we don’t have that

many numbers. So we have four combos. This is like zero, one, two, three. So from zero to three or

four possible combos. And then the end is going to be a zero here and a zero there and a zero there.

So that’s a truth table that just handles that first gate. So then I’m just going to, you know,

write, I mean, you could make another truth table for this, but I’m going to try to write this in a

I’m going to try to write this in a more compact way.

I’m going to say the second column is the result of ending.

The next column is the result of oaring.

And then the last column is the result of,

maybe second to last is the result of an XOR.

And then maybe I’ll make another table for nodding.

So what is the result of an OR here?

It’s going to be a, whoops, a zero.

The OR here is going to be a one.

So when you start to make these tables,

it just makes it a little bit easier to work your way up because when it gets time to let’s say the

not you don’t have to compute all the other things because they’re already computed in the table so

we got the or which i should have probably done first because the second gate was an xor i should

have done that maybe third i don’t know i’m going to leave it as and and or right now and then we’re

going to do xor so xor is basically if exactly one bit is a one will output a one so that’s a one

so that’s a one there and then a one there and then a zero there okay so we’ve got the basics

and if you think about it that’s the whole bottom row right so if we’re just sort of looking at

let’s say the the third gate right here then uh we just have to look at input one one for the or

and then that’s this right here right there so that tells us what the answer would be truth table

for input zero one we just have to go all right zero one xor the output should be a one

and we can double check ourselves because it’s really really easy to make mistakes i’m sure

there’s a chance that i have or will make a mistake pretty soon

so we did and or an xor let’s do maybe just one for the knot just to remind ourselves of what it is

and i’ll just say not and so we can only do two different inputs on the uh on the knot so i’m

so I’m going to go maybe a zero and then a one right here and then the not is going to say we

have a one there and a zero there okay so now we can get a little bit more complicated

by combining these terms so for the input now we could do

we could do uh let’s say two gates at a time so we’ll do the input here and we’ll say the input

1, 0, 1.

And so when we not, when we not the, well, when we do an and for the 1, 1, we can end

up with a 1.

And then when we do an XOR on the 0, 1, then this is not the best truth table, to be honest.

I’m just trying to I’m just trying to do it the XOR is going to be a one so now we kind of have

the results written down here let’s do another little table and you know the way these tables

work is you kind of want to put every possible combination of inputs there but that alone is

going to be so many combinations I don’t want to write it all down and by the time we get to eight

bits it’s going to be like in the 200s so if we just look at the next pair of gates we’ll say

gates will say one one zero zero and the first thing is an or for the one one and

then the next thing is an and for the zero zero and so I can just write this

down and go all right the or is going to be a one and the end is going to be a

zero okay so then I can do another level I’ve pretty much just handled you know

the bottom row here and again each table is supposed to be filled out for every

combination of inputs but I can now just kind of move on to the next row I can say

what is the result of inputting a one and a one you could do that but it might be a little bit

better and closer to some other places that might want you to input this sort of thing

to write down what is the result of the or what is the what are the two gates that are giving you

Okay, so the first input on the very bottom left, that’s an and, right?

And then the next input on the bottom row is an XOR.

And if we’re trying to figure out, you know, how are we combining those?

We could say and XOR, or we can do, you know, two ampersands.

I guess I’m going to do and XOR, just to keep it in plain English as much as I possibly can.

So basically, this is going to have, you know, one result.

this is going to have, you know, one result, you know, one bit result and its input is going to be

a one, one, zero, one. And so maybe I should do another row here. We can say the end

for the end is going to, for one, one is going to be that. And the XOR is going to, well,

I already wrote that down in the table. Okay. I’m just going to, I’m just going to clean it up

because you know, it’s really good in these truth tables. If you write down all

truth tables if you write down all of the numbers, but I’m just going to do it this.

I’m just going to do it this.

Maybe we can visually see that there’s a one one going into the first end and then a zero

one going into the second gate, which is an XOR.

I think maybe that’s acceptable.

So the result of that, if we just sort of look up at this table here, we have, you know,

what is the end and what is the OR?

It’s a one and a one.

So if we end those two together, that should be a one.

that should be a one so that means if we end the and against an xor then that’s the result that we

get and then we’ll make another little table here for the next layer of inputs so i’ll just do this

and i’ll say

or and then the operator that combines them is an or and then on the right side it’s an and

The input to both of those is going to be a one, one, zero, zero.

And again, you should make another row for every possible combination of inputs.

That would be a really smart idea.

So then I will say that, uh, the, or in the end for a one, one and a zero,

zero is this because we already wrote that down in the truth table.

So really we’re going to be looking at inputs of one and zero.

So that means, uh, if we’re applying an, or to that,

applying an or to that, the final result should actually be one.

Okay.

So now we’ve got that second row.

We just have to look at the second to the last row.

So I’m going to go input for an X or of something else.

And the X or is going to be, oh gosh.

of an and

well xor let’s put that in the middle let’s say and on the left and or on the right and then we’ll

do an xor against them maybe you could put the parentheses on the other ones i don’t know i’m

struggling with notation clearly right now but so we say and exclusive or with the or but then what

Let’s put some more parentheses around it and we’ll say the and anded with an X or.

Now we’re running out of room here.

Can I get this like at the top maybe more?

How about that?

Okay, that’s a little bit better.

So we have and being anded against an X or and then I put parentheses around that.

There is a, there are special symbols you can use for this to make it more clear, but

for this to make it more clear, but I’m not really trying to explain that right now.

I just want you to see how the gates work.

So we have, then the next two operators are in, oh gosh, yeah, we’re XORing against two

things.

So on the right side, the OR is ORing and OR, and then on its right side is the AND.

So maybe I should do, I don’t know, I guess I’ll put parentheses right there to make it

seem a little bit more clear.

So now we’ve basically got an XOR and on its left side what’s happening underneath it is an

anding which is the middle of an and on the left and an XOR on the right and then the

the right side of the XOR is

then the the right side of the XOR that was my LL I’m talking to me again

on its left sorry it’s oaring on its on its right and then under the or it’s got an or on the left

and an and on the right okay so we’ve written all these down in a way that’s okay not great but okay

and i’m just going to do one one zero one one zero zero and then um i’ll make another video in the

future about truth tables if everyone is super interested but that’s that’s not really what i

I’ll make a video where the truth tables look proper and nice and full and all that stuff.

So let’s do, what is the answer between the, oh, I have to scroll up a little bit to see that.

So the left side of the XOR had an anding of an and and an XOR.

So that was this right here.

So the result of that was a one.

and an end and that was a one so I have two ones basically so this XOR is going to output

a zero because it’s it’s got two ones as an input or as inputs okay so then I guess I could copy

paste this to make it a little bit easier on myself to write it all out and I could just say

let’s not the whole entire thing to get to that highest level so I you know again I can just kind

I, you know, again, I can just kind of keep the whole thing copy pasted and you know,

the original input bit sequence, uh, I can just nod it.

I can just change that zero to a one.

So let’s just double check all our levels here to make sure that I did this correctly.

You never know.

So the input not, we know what that is for the end and the X or where’s the end and the

X or, okay.

So bottom left.

What did I do wrong?

Input.

Oh, that was, those were just the basics.

Okay.

So that’s not a combination.

Okay, so that’s not a combination.

Let me just double check the basics for the anding.

Zero and zero and zero and then zero and then one and then one.

And then here it should be a one and then the or should be one and should be zero.

And here the and should be one and the or should be one.

Okay, so I’ve got the basics, right?

And then on line 15 here, we’re looking at

an AND and an XOR. I guess I just did both of those at the same time. Okay, so the AND is a

1 and the XOR is a 1. And then the next one, the OR and the AND, it’s a 1 and a 0. Okay.

And then we’re ANDing the AND and the XOR. So that’s a 1, 1, 0, 1. The answer should be a 1.

That matches the diagram. Okay. And then the ORing of the OR and the AND on the right side,

the or and the and on the right side, that’s a one.

So that matches the diagram.

And then when we’re doing the whole thing, except for the knot,

it should be a zero at the top.

Okay, good.

And then finally, when we invert it at the very top, it’s a one.

So keep that in mind.

You can build and build and build in a hierarchical manner.

I mean, think if I started adding a bunch more stuff on top of this knot,

maybe if there were a bunch of other circuits somewhere else

and they were combining and combining like many layers.

This is the sort of thing that could help you.

Drawing, I think, is a little bit easier, but this could help you to just draw out a little table.

And of course, you want to have a giant table showing all combinations somewhere,

just to make sure that you can just look it up quickly.

But yeah.

Okay, so I think this is all I wanted to talk about.

Let me just double check.

All right.

So this is all I wanted to talk about for this video,

about logical gates and the basics and kind of helping yourself with a little bit of a table.

yourself with a little bit of a table. In future videos, I’ll talk about a proper table, perhaps.

And I hope you’ve learned a little bit and laughed a little bit at me struggling to do this on the

fly without a pre-made example. And I hope you had a little bit of fun and learned a little bit

of stuff. And I’ll see you in the next video. Thanks for watching. Hey, everybody. Thanks for

watching this video again from the bottom of my heart. I really appreciate it. I do hope you did

If you could do me a please a small little favor

Could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media?

It’s a website that you’re looking at right now

It would really mean the world to me and it’ll help make more videos and grow this community

So we’ll be able to do more videos longer videos better videos or just i’ll be able to keep making videos in general

So, please do do me a kindness and and subscribe

I’m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.

It just wakes me up and I get filled with joy.

That’s exactly what happens every single time.

So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.

Just subscribe and then I’ll just wake up.

I promise that’s what will happen.

Also, if you look at the middle of the screen right now, you should see a QR code which you can scan in order to go to the website,

which I think is also named somewhere at the bottom of this video.

and it’ll take you to my main website where you can just kind of like see all the videos I published and

the services and tutorials and things that I offer and all that good stuff.

And if you have a suggestion for clarifications or errata or just future videos that you want to see,

please leave a comment.

Or if you just want to say, hey, what’s up? What’s going on?

You know, just send me a comment, whatever.

I also wake up for those in the middle of the night.

I wake up in a cold sweat and I’m like,

it would really mean the world to me.

I would really appreciate it.

So again, thank you so much for watching this video

and enjoy the cool music

as I fade into the darkness,

which is coming for us all.

Thank you.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply