Raspberry Pi Pico W LESSON 3: Understanding and Using Binary Numbers
Estimated read time: 1:20
Learn to use AI like a Pro
Get the latest AI workflows to boost your productivity and business performance, delivered weekly by expert consultants. Enjoy step-by-step guides, weekly Q&A sessions, and full access to our AI workflow archive.
Summary
In this engaging lesson by Paul McWhorter, viewers dive into the world of binary numbers, crucial for understanding the operations of digital computers. From explaining how computers work on the fundamental on/off principle to showcasing how numbers, letters, colors, and even videos stem from binary, this tutorial helps demystify the complexity of digital systems. McWhorter uses the SunFounder Kepler Kit for Pico W to practically teach binary counting with LEDs, challenging viewers to build their binary counter and share their projects online.
Highlights
Binary is the language of computers, using 0s and 1s to represent all data! 🖥️
Learn how to convert decimal to binary and vice versa effortlessly. 🔄
Create a unique binary counter using LEDs and a Raspberry Pi Pico W. 💡
Explore the process of adding binary numbers and see how it’s equivalent to decimal arithmetic! ➕
Dive into a mind-blowing understanding of digital images and colors through binary. 🌈
Key Takeaways
Binary numbers are fundamental to digital computing, representing on (1) and off (0) states. 💡
Understanding binary enables manipulation of digits, colors, and images digitally. 🎨
Construct a binary system using simple switches to build numbers and perform math operations. ⏯️
Viewers are encouraged to engage in a hands-on project to reinforce their learning. 🤓
Paul emphasizes community learning by sharing projects on YouTube for feedback. 🌐
Overview
Have you ever wondered how the amazing world of computers comes to life? Well, it all boils down to the magical world of binary numbers, and Paul McWhorter is here to guide you through it all! In this lesson, Paul explains why binary is the backbone of computing, illuminating how digital devices translate zeros and ones into complex operations that make up our digital experience.
With his trusty Raspberry Pi Pico W and the SunFounder Kepler Kit by his side, Paul gets down to the nitty-gritty of binary numbers, demonstrating how gadgets work at their core by flipping simple binary switches. As you grasp the concept of zeros and ones, you’ll learn to build a binary counter using LED lights, enhancing your understanding of how computers perceive data.
But that's not all—Paul's real stroke of genius is not just in teaching binary arithmetic; it’s about making the learning process interactive. Encouraging everyone to share their binary projects on YouTube fosters a community of learners who can learn from each other’s work, transforming a seemingly dry subject into something dynamic and vibrant!
Chapters
00:00 - 00:30: Introduction and Ice Cold Coffee The chapter, titled 'Introduction and Ice Cold Coffee,' is part of a tutorial series hosted by Paul McCarter on toptechboy.com. This particular episode is the third installment aimed at helping viewers 'Unleash the Power of your Pico W.' The session opens with Paul encouraging viewers to enjoy a glass of ice-cold black coffee without any additives.
00:30 - 01:00: Sponsorship and Hardware The chapter discusses the sponsorship from Sun Founder for a series of video lessons, highlighting the use of the Sun Founder Kepler kit for the Pico W. It acknowledges that while many viewers may already have the required gear, there is a link provided in the description for those who need to purchase it via Amazon.
01:00 - 03:00: Importance of Binary Numbers The chapter begins with a discussion on the benefits of using similar hardware for ease of communication and collaboration. The narrator moves on to the main topic, which is the importance and magic of binary numbers. There is an explanation of why binary numbers are important, setting the stage for a deeper dive into the topic.
03:00 - 04:00: Basics of Binary Counting The chapter titled 'Basics of Binary Counting' delves into the fundamental concept underlying all digital computers. Despite the diverse range of digital devices, from desktop PCs and Macs to Arduinos and Raspberry Pi Pico W, they all function based on a simple principle. At their core, computers only understand two states or values: on and off. This binary foundation is what enables computers to perform a multitude of complex tasks, as emphasized in the chapter's discussion.
04:00 - 07:00: Decimal and Binary Comparison The chapter discusses the fundamental structure of a computer chip, emphasizing that it consists of a large number of simple devices known as switches. These switches operate in an on and off mode, contributing to the chip's functionality.
07:00 - 10:00: Adding Binary Numbers The chapter "Adding Binary Numbers" looks at the foundational concept of binary numbers in computer systems. It explains that a binary switch can either be in an on or off state, which aligns with the binary number system consisting of ones and zeros. This chapter emphasizes understanding how these states form the basis for operations in computing, where everything must be converted into binary. The discussion begins by introducing this abstract concept and its critical role in computer operations.
10:00 - 13:00: Math in Binary In the chapter titled 'Math in Binary', the concept of binary numbers is introduced, specifically focusing on how binary uses only two states, represented as 0s and 1s. The chapter explains that a single binary switch can be either on (1) or off (0). This understanding is crucial as it forms the basic unit of binary arithmetic and logic used in computing. The chapter sets the foundation for dealing with more complex numbers and operations in binary by explaining how billions of these switches enable complex computations.
13:00 - 15:30: Application of Binary in Colors and Images The chapter explores the foundational role of binary code in computing, particularly focusing on its application in colors and images. Binary represents information using a system of 0s and 1s, which is integral to how computers operate at the hardware level. Understanding binary is crucial for working with computer hardware, particularly at the silicon level. The chapter begins by emphasizing the importance of representing numbers in a binary format to interact with computer systems effectively.
15:30 - 18:30: Homework Assignment The chapter titled 'Homework Assignment' discusses the fundamental concept of digital information representation. It explains how binary numbers, consisting of zeros and ones, can be used to create numbers. These numbers, in turn, can be assigned to letters, enabling the formation of the entire alphabet. Furthermore, by utilizing binary numbers, it's possible to generate not only letters but also colors, pictures, and even videos. The process essentially begins with understanding how on and off switches (interpreted as zeros and ones) are the basis for representing multifaceted digital content.
18:30 - 21:00: Conclusion and Call to Action The chapter titled 'Conclusion and Call to Action' begins with an explanation meant to deepen the reader's understanding of a specific subject. The speaker plans to guide through the process using a sketch pad to illustrate points that are being discussed. There is a slight technical concern with the sketch pad possibly turning off, but reassurance is given as the session continues. The focus of the chapter is to refine the understanding of converting ideas (possibly numbers) into desired results, emphasizing the importance of fully grasping this concept.
Raspberry Pi Pico W LESSON 3: Understanding and Using Binary Numbers Transcription
00:00 - 00:30 hello guys this is Paul McCarter with toptechboy.com and we're here today with episode number three in our incredible new tutorial Series where you're gonna Unleash the Power of your pico W what I'm going to need you to do is pour yourself a nice tall glass of ice cold coffee that would be straight up black coffee poured over ice no sugar no sweeteners
00:30 - 01:00 none needed and as you're pouring your coffee as always I want to give a shout out to our friends over at Sun founder Sun founder is actually sponsoring this most excellent series of video lessons and in this class we will be using the sun founder Kepler kit for the Pico W now I know a lot of you guys already have your gear but if you don't look down in the description there is a link over to Amazon you can hop over there
01:00 - 01:30 and pick a kit up and believe me your life in my life are going to be a whole lot easier if we are working on identical Hardware but enough of this Shameless self-promotion let's talk about what I am going to teach you today and what I'm going to teach you is I'm going to teach you the secret and the magic of binary numbers now why are binary numbers important well first of all we have to kind of think about
01:30 - 02:00 computers whether we're talking about a desktop PC a Mac an Arduino a Raspberry Pi Pico W every single digital computer in the world operates based on a very simple concept now you look at a computer and you think of all the incredible things it can do and therefore all the incredible things that it can it must know but really the computer Only Knows two things on and
02:00 - 02:30 off now what do I mean by that I mean that if you look at a computer a computer chip whether it's the Pico W or an Intel processor or whatever that computer chip is made up of a very large number of a very simple device a very large number of switches a very large number of on off switches and so the
02:30 - 03:00 only thing that that switch knows if we look at one switch the only thing that that switch knows is either on or off it knows either on or off and so everything that we're going going to do with the computer we have to be able to turn it into the simple concept of binary on or off now on or off that's kind of an abstract concept and so if we want to
03:00 - 03:30 start dealing with numbers our colors or things like that we need to have something other than on or off and so what we're going to call that is a 0 or a one so one individual switch can be on or off if it's on we're going to call it a one if it's off we're going to call it a zero okay and if we have one switch we have on and off if we have billions and
03:30 - 04:00 billions of switches what we just have is billions and billions of zeros and ones and so everything on a computer is based on zeros and ones and therefore if we're really gonna get in and start working with the hardware and start working kind of down at that silicon level we really have to understand binary so the first thing we need to do is what's kind of like of all the things that you might want to know we've got to be able to represent numbers when all
04:00 - 04:30 we've got is zeros and ones now if we have numbers we could assign numbers to letters and therefore we could make any letter that we wanted by assigning a number to it and therefore if I can take zeros and ones and make numbers I can then make letters and I can make colors and I can make pictures and I can make videos but it all comes down to that first step of taking on off switches thinking of them in terms of zeros and
04:30 - 05:00 ones and then turning that into whatever number that we might want okay does that make sense you really need to understand that so I'm going to kind of take you through that today and we're going to switch over here to our sketch pad view with a little bit of luck of course I always kind of panic when I go to sketchpad because it turns off and then we always hope that it turns back on and there it is okay so before I really talk about
05:00 - 05:30 binary numbers zeros and ones let's think about our good old fashioned let's think about our good old-fashioned digital numbers okay and so let's think what is our very first number now you might say one but really our first number is what our first number is zero okay and so zero has its own unique
05:30 - 06:00 character now the next number is what it is one okay I have a unique character for that now if I add another one zero plus one is one one plus one is what two the next number is two and then three and then four and then five and then six and then seven and then eight and then nine and now what has happened
06:00 - 06:30 what has happened I've run out of unique characters I've gone through all my characters that's a total of ten zero through nine is a total of 10 characters I've run out but I need to go one more and so if I have nine and add 1 to it don't say 10 if I had nine and I add 1 to it I've got a what I've got to go back to zero
06:30 - 07:00 and then what and then carry the one and that's what I need you to think of 9 plus 1 is not ten nine plus one is zero carry the one now why did I have to loop back to zero I ran out of characters okay well what if I just had three characters what would I do if I just had three characters I would go 0 1
07:00 - 07:30 I am out of characters what do I need to do I've got to loop back to zero and then I've got to carry the one and so if I only had three characters the way that I would represent the number three is what one zero so it's just completely random that we have 10 characters and all of our math is based on 10 characters we could come up with a completely
07:30 - 08:00 different number system we go 0 1 2 and then 0 carry the one and really you think about it it doesn't even have to be those characters let's go back to the ancient civilization of mu which was kind of like Atlantis but it was in the Pacific and let's say they had the first character a square and then they had the next character a triangle and then they had the next character a circle with a dot in it and then uh oh they're out of
08:00 - 08:30 characters what do they have to do well they're going to have to go back to the uh they're going to have to go back to the square and then they're going to have to what carry the triangle okay so do you see you could come up with an equally valid number system based on any number of characters and based on any different type of character by the way I have no idea what the people of mu use to count
08:30 - 09:00 but I just made that up all right but it would work I could develop all of mathematics based on what I just showed you there but the digital system is isn't going to work for computers because why I don't have 10 different characters the move system isn't going to work why because I don't have three different characters how many characters do I have I have two on or off which we're going to say is a 0 or a
09:00 - 09:30 one so let's come in here let me see if I can just kind of back up here I think I'll just clear this out okay so now let's say that we have a computer and we have four switches and those four switches can either be on or off and now what I want to do is I want to count
09:30 - 10:00 well where did we start we started at zero and so that is where we are going to start in our new counting system which is binary which is the computer system which is just based on zeros and ones so let's see if I can get over here and so remember we're going to have four characters or we're going to have four switches so zero zero zero zero everything is what everything
10:00 - 10:30 is off now I am going to add 1 to it and so that is going to be zero zero zero and then I add 1 to the 0 and I get what a one so the number zero in binary is zero zero zero zero the number one in binary is zero zero zero one now I need to go to two what is the problem I'm out of
10:30 - 11:00 characters right I am out of character so I am sitting right here with a problem because I want to go from one to the next character I don't have the next character so in binary one plus one is what don't say two one plus one it's what one plus one is zero
11:00 - 11:30 carry the one okay and then zero zero and so this number is the number this number is the number zero this number is the number one and this number is the number two and over here I'm going to do decimal okay and then over here we're doing binary okay
11:30 - 12:00 now I meant 2 I need to add 1 and go to 3. so this one's going to be easy because it's just going to be 0 0 I still have the 1 and then 0 plus 1 is what one like that okay now that would be the number three now I need to add one well what would happen 1 plus 1 is what 1 plus 1 is 0
12:00 - 12:30 carry the one but now there's already a one there so I got one plus zero is I mean I've got one plus one is zero carry the one now I'm going to have one plus one again is what 0 again carry the one like that okay and let's go ahead and fill these in that is 3 and that is 4. like that okay now I'm going to add one this one's
12:30 - 13:00 easy right if I add 0 and 1 is 1 no carrying and so this brings the zero this brings the one this brings the zero now I add one one plus one is zero carry the one and that's easy because zero plus one right and now this comes down one and zero now adding one again is easy again what is that going to be it is going to be a one
13:00 - 13:30 okay zero plus one is one and then I bring down the one bring down the one and zero okay and let's fill these in this is the number five this is the number six and this is the number seven all right now I know this gets tedious but you're gonna start it's going to start making sense if you just keep listening to me now I wanna add one what is the problem one plus one
13:30 - 14:00 one plus one is what it's zero carry the one but now I have a one there so again it's going to be one plus one is what 0 carry the one there's a one there so it's going to be one plus one is what zero and then carry the one that was a hard one because we were doing a lot of carrying now we add one and it's easy it's just one zero zero one now I add one one plus one is what zero carry the
14:00 - 14:30 one zero one now I add one and I get a one no carry I bring the one down zero one ah now it's going to get another tricky one I add one one plus one is zero carry the one so I'll have then a one plus one is zero carry the one and a one now let's go ahead and fill these in so this is an eight
14:30 - 15:00 a nine a 10. and 11. and a 12 we're getting on down here now I add 1 0 plus 1 is 1. 0 1 1 and now I add a 1 1 plus 1 is 0 carry the one okay a zero carry the one and then I'm
15:00 - 15:30 going to have a 1 and a one okay and so now this is going to be a 13 okay and now this is going to be a 14 and then I have one more I'm going to have a add a 1 and that's going to be 1 0 and 1 is 1 and then a 1 and a 1 and a
15:30 - 16:00 1. and so that is going to be the number 15. so what does that mean that means that if I have four switches I can have can't count how many numbers from 0 to 15. pretty cool right pretty cool now so you see that for for every decimal
16:00 - 16:30 number I can create a binary number well what if I wanted to do one million two hundred and thirty seven thousand four hundred and fifty six well I would just need more switches I don't want to count through all of those but I think that you see the pattern if I wanted to go to 16 I would need one more switch and then it would be one zero zero zero zero right I would have to carry the one carry the one carry the one carry the one and then fill in that uh that fifth switch okay
16:30 - 17:00 now I want to kind of show you how you can go from decimal to Binary and from binary to decimal first of all what I hope that you can see is I hope you can see that I can create a binary value I can create a binary value for any decimal number but when you want to go to a a big number you don't want to have to go in and count your way down so I want to kind of show you how you can go from binary to decimal and decimal to
17:00 - 17:30 Binary and so what I want you to see is is that you got to think about this as kind of placeholders right you've got to kind of think of this as place values these four switches okay these four switches are place values this first switch this first one here how much is that place value worth it's worth one okay just one so anytime you see
17:30 - 18:00 this column turned on that is going to be worth one now how much is the next one worth well the next one is worth how much it's worth two okay the next one how much is it worth it's worth four like that and then this next one over it's worth what it is worth eight
18:00 - 18:30 okay and so I uh I just really uh I really wish I'd done that better but let me draw it over here so that you can kind of see it bigger this is worth one this is worth two this is worth four this is worth eight if we had another one a fifth one it would be worth what sixteen if we had a six one it would be worth 32 64 CC how you can
18:30 - 19:00 very quickly go on out and so now let me just really come in here very quickly and very simply and let's say that we are going to take let me just arbitrarily pick this number this binary number one zero one zero and what would that be worth well I've got one two and then I've got one what out here 1 8 and 8 plus 2 is what 10 and that works
19:00 - 19:30 out or what if I just took this one well I have a what I have a ones place and then I have a fours place and four plus one is five you see it works out now let me show you the really really cool thing let me show you the really really cool thing let's just say that I took let me just make something up let's just say I took 0 0 1 1 and I wanted to add to that
19:30 - 20:00 0 1 1 0 I want to do math like that I have two numbers and I'm going to do math so 1 plus 0 is what it's a one one plus one is what it is a zero and carry the one now one plus one is what zero carry the one and then come down with a one so Z 0011 plus zero one one zero is the
20:00 - 20:30 answer one zero zero one well now first of all let's say what is 0 0 1 1 well we can come over there and see that zero zero one one is the number what it is the number three what is 0 1 1 0 0 1 1 0 is the number what it is the number six one zero zero one what is one zero zero one
20:30 - 21:00 right there one zero zero one is nine so do you see that you can work it in binary and it gives you the right answer okay it gives you the right answer let me try to do one more just for fun let's say what is what is 0 1 0 times 0 0 1 1. we just do long division what is
21:00 - 21:30 one times that number I'm going to take this one and that is going to be 0 1 0 0. now I got to do this one and that's going to be zero one zero zero and then the 0 is going to be zero zero zero zero and this 0 is going to be zero zero zero zero now I sum them up this is zero one one zero
21:30 - 22:00 okay now what is this number zero zero one zero is two zero zero one one is what three two times three is what six now what is 0 1 1 0 0 1 1 0 here is six so you see I could even go in and I could do long division and so what I want you to see is binary is just as valid of a number
22:00 - 22:30 system as decimal is okay and so what I've shown you is I can count in binary I can add in binary I can subtract in binary multiply and binary divided in binary so any math problem I can solve in binary why is that important because I can Implement binary with on off switches which is what I have to work with on a computer now is this really
22:30 - 23:00 cool stuff or what I think this is just super cool so like uh how do you get a color well for a color like let's just do a grayscale okay like what is this that is white and so what we could say is we could we could say remember how it goes to the powers of two well let's just say from 0 to 250 or let's say 0 to 255 we're going to do our strength of colors okay and if I have 255 then that thing
23:00 - 23:30 is going to be solid black okay it's going to be solid black if I have 0 that's going to be so this look let's do it the other way let's say let's say that that the absence of any color at all would be zero okay and then if we're full on this would be 255 and then like if I have a gray
23:30 - 24:00 like this that could be like 125 and then maybe like uh almost completely wide could be 250. so you see you can take a number between 2 0 and 255 and you can go from white to black okay what you could also do is instead of just having one number what if we had three numbers okay and one number is going to represent the red
24:00 - 24:30 value the next number is going to represent the green value and the next number is going to represent the blue value and then I could have something like let's say that I could have uh I could have uh red is zero okay and let's say I could have green is 2 I could have green is [Music]
24:30 - 25:00 255 and let's say I could have blue is 255 and then green and blue would make what color it would make purple so you see I can make gray scale I can make colors now if I have a whole bunch of these little pixels of different colors then I have a what I have a picture now if I show one picture after another I have a what I have a movie okay so you see I can go from zeros and ones to
25:00 - 25:30 numbers to grayscale to colors to pictures to videos but it all comes down to zeros and ones and it is a completely new way of doing things all right so you can see how I can do the math and you can see how I can do colors and you can see how I can do all of that this is going to be your homework assignment what did we do last week let's see if I can come in and show this okay that's not it
25:30 - 26:00 or is that aggravating thing there it is okay so what is that led it's going on and it's going off on and off tell me what that means in binary think about it say it out loud one zero one zero one zero okay so this is what I want you
26:00 - 26:30 to do I want you to create a circuit okay I want you to create a circuit now right now you have a circuit with how many LEDs one I want you to create a circuit now with how many LEDs I want you to create a circuit with four LEDs one to two three four and those are all off so that is
26:30 - 27:00 the number what that's the number zero now what would be the next binary number would be zero zero zero well I can't make a one but I could do what I could turn this led on and then when you see this physically in front of you that is the number one now what would the next number be it would
27:00 - 27:30 be zero off of what on and then off and that is the number two and go back and look at that versus our earlier thing and so what I want you to do is I want you to make a binary counter you will have four LED each LED needs its own what current limiting resistor so you will have four
27:30 - 28:00 resistors how many gpio pins will you need you will need to use four GP G [Music] p i o Pence you will need four of those and then how many grounds will you need you'll just need one ground because everything can connect to the same ground and so you'll need one ground and then remember what we learned last week
28:00 - 28:30 on the uh on the kind of what you can do with that top row on your breadboard that will make your life a lot easier but you guys do a really neat build like when you come over here and you look at this you see this is a really neat build but you don't want your LEDs all over the all over the place you see you see how I have one up there you see how pretty that one is well what I want you to do is I want you to come up and I want you to have four LEDs side by side like this and then I want you to count 0
28:30 - 29:00 to 15 and then once you get to 15 you need to go back to what go back to zero so it should count 0 to 15 back to zero zero to Fifteen back to zero guys I have taught you in the first two lessons in today's lesson everything that you need in order to do this homework so I need you to do the homework now when you do the homework I want you to remember what do you always do after you do your homework you post your homework solution
29:00 - 29:30 to YouTube even if it is simple your video production has to be it doesn't have to be great even if it's as simple as just pointing your phone at your computer screen and then showing what your code is and then pointing it down and showing the circuit operating Post Your solution to YouTube in the description of your solution link back to this video then in the comments down below leave a link over to your homework
29:30 - 30:00 solution so that I can look at your homework solution and other people can look at your homework solution then read through the comments and you guys look at each other's Solutions because I want you to kind of get to know each other start working together talking about these projects together okay I hope that makes sense man this is a really fun and cool project and I don't know the first time I really understood binary it kind of blew my mind and it really blew my mind when I was doing math and binary it sure enough it was giving me the correct
30:00 - 30:30 digital answers so I really want you guys to do this homework if you like this video be sure to give us a thumbs up if you have not already subscribe to the channel when you subscribe to the channel make sure you ring that Bell so that you get notification when future classes are released and most importantly share this video with other people because the world needs more people doing engineering and fewer people sitting around watching silly cat videos all mcquarter with toptechboy.com
30:30 - 31:00 I will talk to you guys later [Music]