Transcript for:

hello guys this is Paul McCarter with toptechboy.com and we're here today with episode number one and 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 none needed and as you're pouring your coffee 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 tutorials and in this class we will be using the sun founder Kepler kit for Raspberry Pi Pico W the Pico W now most of you guys probably already have your gear but if you don't look down in the description below there is a link over to Amazon and you can pick this kit up and believe me your life and 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 jump in and talk about what I am going to teach you today I'm going to basically teach you three things I'm going to teach you how to configure the Pico W so that you can begin to program it I'm going to teach you how to get your PC set up so that you can interact with the Pico W and then the third thing is we're going to write like our first four programs and my goal is to do all that in under 30 minutes the first thing that I should say is I want to talk a little bit about the prerequisites for this class for this class I do not assume that you already have a PhD from MIT in computer science I don't assume that you already know what all the words mean I assume only two things that you're willing to pay attention and that you're willing to work real hard you don't have to come into this with any prior knowledge I'm going to start you at absolutely Square One absolute beginner and then we're going to go all the way up to some really neat and cool and exciting projects before this thing is over sound good I hope so so let's see what do we need to start with well we probably better go ahead and get out our Pico W out of the kit and so what I'll come here is I'll put the kit here I guess I better get out of your way as well there we go okay and then you can see I have my kit here and we're going to open it up and oh wow look at all of that delicious electronic goodness that we have in here so I'm not going to go through and talk about all these components but we do need to today find the Pico W and for me it is on the second level of the electronic components and it is a little package like this just a little green single board computer so we're going to get that thing out and then we are going to come over here get this out of the way and then I think I will switch my view so the first thing that I want to do is to connect this to my computer through the USB cable so also in here you probably already have one of these micro USB cables you can use one that you already have or I think there's a short one in here you can use the one in here if you want but you should have a USB cable connected up to your PC and now we are going to get out this little marvelous Raspberry Pi Pico w okay get it out and then I'll come here in View and I'm going to go ahead and take this off and then I'm going to take this off and then the first thing we want to do is just to kind of get this to talk to we want to get this to talk to our uh PC that just to sort of see the USB so you can see here what I have is I have the disk PC view window open up on my PC and what I want you to see is that if I just come in and I just plug this in I hear the little USB ding dong but what you'll notice here is you'll notice uh you'll notice over here that I didn't see any device show up okay so it's not recognizing it as a USB device and so I want to show you the key thing now normally you just plug it in but as we're getting this thing configured the first time we have to make it a recognizable USB drive and the way we do that let me unplug it and then what I'm going to do is I'm going to hold the little white button down and then I'm going to come in and plug it in and giddy up what do you see that happened that time now we see the RPI rp2 show up as an F drive now I can put something on it now what we're going to be operating on in this class is micro python so I've got to go out and I've got to get micro Python and I've got to put micro python on my Pico W what's the good news is my PC is seeing the Pico W and gives me shows it to me as a little USB drive so we're doing great so now what we need to do is we know need to go out and get we need to go out and get the micro Python program so I'm going to search on Raspberry Pi Pico micro python installation something like that and then for me the first result is the raspberry pi.com documentation microcontrollers and so forth and so that is the one you're going to want and then you should come up with a page that looks something like this okay what is micro python very good and then this is the drag and drop micro python installation and that is what we want now there's two possibilities the Raspberry Pi Pico or the Raspberry Pi Pico W because of our friends over at Sun founder we have the ultimate chip which is the Pico W so we will be selecting that one and then you see the download begins down here and then boom there is my download okay so now what I'm going to need to do is I'm going to need to keep that in View and I'm going to need to come back over here and then I'm going to need to click on this and so you see now it's showing up as a drive and now I just come over here and that file that I just downloaded I'm going to come over here and I'm going to drag and drop it there now it you can see that it's copying that's good you might not even see it here you might not see any difference but let's give it a chance to download okay there it is so boom we are done now when I got that file let's look and see something interesting that happened uh let's see if I come back over here and I go back to this PC now once it got that operating system once it got that micro python environment now it is no longer showing up as a USB drive that's okay because we got what we needed there so the first goal we have met what have we done we have got the uh micro python loaded onto the Pico W and so that is a great step forward that we've made there now what's number two we need to create an integrated development environment on our PC that will allow us to download programs down into the Pico W if that makes sense okay so what I'm going to do there is I'm going to come down come back over here and the integrated development environment that we're going to use is thoni okay it is thoni so I will come here and what we're going to say is install fawnee something like that should be good enough okay thoni python IDE for beginners that is it and then right here we have the download button and this looks good and so we're going to come here to Windows you might be on Mac or Linux but I'm on Windows and I'm going to go ahead and download download the 4.0.1 now if you have a more modern Windows operating system it probably is going to throw a warning when you try to install if it doesn't then no problem you're good to go if it does I'll kind of show you how to take care of it so thawny has been downloaded I'm going to go ahead and click on this and see if I can do the installation when I click on it this little box comes up and it starts trying to tell me to like go get this from the App Store but it's not on the App Store but if you scroll down you'll see change my app recommendation settings so I'm going to click that and what you can see is is that without asking you Windows has set the default to only install apps from the Microsoft store well what I want to do is just say come up and install from anywhere because I'm going to be careful about what I do you got to think about how you want to set things but I'm going to say from anywhere and so that should be good to go now we will come back over here to get back to that download I'm just going to go to my downloads folder there is the download that I just did and let's try to run that and it says install for me only install for all users I'll go ahead and install for all users are you and of course it asks me do I really want to install yes I want to install and then we'll get this little dialog box and then I'm going to say welcome to thawny okay next I accept I probably am giving away my left kidney by agreeing to that in firstborn grandchild I'll say next next and then let's go ahead and create a desktop icon and then we will install this should go pretty quickly now it's like the longer I use Microsoft the more annoying it gets and uh the fact that it doesn't allow me to just install where I want and you got to sit and Fiddle with it to finally get it where you can install software is indeed getting a little bit annoying okay we are almost there and and compiling standard library takes a while okay boom finish and we are there so now where are we where are we right now we should have the micro python environment on our Pico W okay and now we should have thoni on our PC so I'm going to come down here and I'm going to now just look and I'm going to say thawny and there it is it pops right up there and so let's see if we can open up Bonnie excellent most excellent okay and uh you guys might have like a little like the first time you run it you might have a little thing that says like you know run the classic or run the standard you might have a little link uh you might have a little link over here that you click on a little link over here that you click on and then it will bring these on it'll bring these menus up for you and since I had installed it and uninstalled it and then installed it again it seems like it's gone back to my old preferences but that's not a that's not a big deal you should be able to have a little blue icon here that you click on and then you will get these uh these menu items okay the first thing that we want to do is we want to connect Thani to we want to connect thoni to the Raspberry Pi Pico and so let's see if I can get a nice view here where you can see both of those things I think I can get this all working so uh I think that looks pretty good now the first thing is mine it looks like has already connected up it's this micro python Raspberry Pi Pico com7 it seems like that it is connected but you can come down here and then click on this and you can go to local python3 if you did that whatever you wrote in Bonnie whatever you wrote in thoni would run on your PC or you can come down to micro python Raspberry Pi Pico com7 that will run it on the picot so that is what I'm going to select now for me it was already selected but you need to make sure that it is selected okay guys I believe that we are ready to go so right now we are execution ready so if I just type a line of code here it it should uh it should execute it so let's say print and then I'm just going to say hello world like that and Giddy Up wrote our first program hello world well actually we didn't write our first program we just executed our first line of code so when I type this in what happened when I pressed enter it sent it through com7 down to the Pico W and then the Pico W printed hello world and that came back up through com7 through the IDE and then it printed it out but really what you want to do is you want to write your programs up here where you're writing a program you're writing a program and then executing them so here I can say print hello world like that and then close it and then close it and now I just come up to this little green arrow and then giddy up hello world so we wrote our first program well let's just try like a really simple program what if I say a is equal to 7 and B is equal to 2 and then C is equal to a times B and then what if I say print see like that just a very simple little program and let's run that 14 okay first couple of programs and we are just flying through this stuff okay that stuff is good that stuff is fine what have we done so far we have got the micro python on the Pico w we have an IDE over here on our PC thawny that allows us to interact with the Pico W and now I want to go one Bridge further in this introductory lesson and I want to show you how you can start interacting with the gpio pins now gpio means general purpose input output and you can see there are all these pins on the Pico W and what we can do is we can programmatically interact with those pins and we can send data to them or we can read data from them and there's all types of different stuff that we can do what I want to show you very quickly and easily is just our very first little program where we're going to turn one of those pins on we're going to set it to 5 volts and then I'm going to show you how to do that now the pin that I'm going to be doing working with is called the LED pin and it is a pin that is actually connected right here to this little LED so if I turn that LED pin on what should the LED do somebody tell me what should the LED do okay so let's go in and let's write this program so I'm going to start from uh I'm going to start and if I'm going to work with those pins I'm going to have to import the library that works with the pin so I'm going to say from machine I'm going to import the library pin so the library is I'm sorry the library is machine and then the method that I am importing is pin now what I need to do is I need to create my LED so I'm creating an object I can call this object whatever I want I'm going to call it my le Ed so I'm creating this little object called my LED and that is equal to that method that we just imported pin right so it's going to know what pin is because I just imported pin and then I've got to get it give it some parameters what pin do I want to interact with Well normally you would say like pin one pin two or you know like pin one pin two pin three pin four pin five pin all these different numbered pins but I'm going to use that special pin which is called LED like that and so that's how we do that and now I've got to tell it is it an input or an output well if I'm reading data from it it would be an input but if I'm sitting sending data to it it's going to be a what an output so the way I do that is p i n because again that is this method up here it's going to know what that is and then what do I need to do I need to say it is a DOT o u t case is very important here so what does this line of code do it creates an object that object is my LED and then where is my LED well it is the special pin the LED pin and then I am setting that to be an output does that make sense I hope it does now I can give what my LED that's my object I can give it a value okay now a one is on and a zero is off so if I want to turn it on I need to put what here A 1 like that all right now I have written my first very very simple little program okay I will need everyone to hold their breath as we run this giddy up did you see that look at that we turn that sucker on all right we are in our first lesson we're already interacting with our gpio pins okay if I can turn it off what should I also try to do I mean if I can turn it on what else should I try to do and try to turn it off well if I wanted to turn it off what do you think I should do I should come in here and I should make this a what I should make that a zero like that and so I will come in hold your breath boom look at that we turned it on we turned it off now I'll show you there's also a different way that you can turn it off I've showed you one way well another way you could do it is you could just say uh you could just say turn it on like that okay and now you don't put anything inside of the parentheses and we go there boom it's on and then we could also turn it off by just making that off like that and boom it went off I don't like the on off business so much I would rather do a value and then I would rather make the value one like that that's just a little bit about how I would like to do it okay I do a one and then I go back as zero and then like that okay very good so we're making it through this stuff pretty quickly if I can turn it on and I can turn it off what would be a cool thing to do I would want to what if you can turn it on and you can turn it off you could what you could make it blink but if you're going to Blink you wouldn't want to write a thousand lines of code uh you know my LED value 0 my LED value one zero one zero one you want to somehow create a loop where you create a little bit of code that it just keeps doing over and over and over and luckily there's a way to do that and what it is it's called a while loop and I can just say while and then it will keep doing the code beneath the while as long as the condition is true well what condition is I'm going to put in here I'm just going to say true like that when is true true true is always true and so this is going to Loop forever now to create the the while loop you need to end it with a colon that's very important and then what all is going to be in the loop well everything that is tabbed over so I'm going to come in and I'm going to tab that over so everything all the lines of code that are tabbed over are going to be the parts that continue to Loop so I'm going to I'm going to import the library one time I'm going to make the object and make it an output one time and then whatever I put here I'm going to Loop and so if if I want to Blink I'm going to turn it on and then what would I want to do I would then say my LED dot value is what 0. now what is going to happen now what we think is going to happen now is it is going to what it is going to Blink so I need everyone to hold the breath and [Music] oh oh I'm sorry my LED I had a problem there so I will say my LED light that somebody didn't hold the breath everyone hold their breath this time and deny what do you notice here it's not blinking it just seems to be a little bit dimmer so I want you to think about I said turn it on and I said turn it off but it doesn't seem to be blinking what do you think the problem is okay let's think about this do computers work very very fast or very very slow they work very very fast so what am I doing here I am turning it on and I'm turning it off and I am turning it on and I'm turning it off so fast that I can't even perceive it it might be thousands and thousands of times a second so what do I need to do I need to slow it down so what do I need to put in I need to turn it on and wait and turn it off and wait so I need some what I need some weights or I need some delays and so the good news is there is a different library in Python called sleep so I'm going to say it's called time so I'm going to say from time that's Library import the method which is sleep like that okay from time import sleep and I don't remember if sleep is uppercase or not maybe it's a lowercase let's just see if that will work and if it doesn't then we will find out really quick now what I'm going to say is sleep and how long do I want to sleep let's sleep for one second and then if this doesn't work we'll fix it really quickly I'm just forgetting if it's uppercase or lowercase sleep one so this time what's going to happen we're going to set things up one time and then I'm going to turn it on I'm going to wait one second I'm going to turn it off and I'm going to wait one second and now let's see what happens okay watch ah giddy up look at that on a second off a second on a second off a second boom we've got this thing working okay that is pretty darn good now what you can also see is is that we could make it go faster right instead of that we could come in and say let's go on for point one and let's go off for point one let's see what happens there you guys keep your eyes on the uh on the blinking LED there come in and shoot it and look at that boom boom boom boom boom boom boom boom that is looking really really really good so let's uh let's stop that and you could also do like uh okay yes stop okay you could come in and you could say let's leave it on for a tenth and then let's leave it off for two seconds you see you could do something like that an asymmetric blink and we'll come in run it okay boom Boop you see how we can customize how this thing is behaving man it's just like the first lesson in your already programming gpio opens how cool is that okay I'll show you one other little thing that you can do with these is that instead of saying turn it on or turn it off what you can do is you can toggle and toggle just makes it if it's on it turns it off and if it's off it turns it on and so here I could just come in and say toggle like this and now I only have to do one statement but in this case it's always going to kind of be symmetric if it's on it'll go off if it's off it'll go on and so let's run this look at that okay so man you've learned a lot of really cool stuff okay this is your homework assignment look over what you've learned so far look over what you've learned so far in today's lesson and then be able to go back and write this code without looking at what you've already done so be able to write this on your own so get familiar enough with it that you're not just going back and re-copying it but doing it on your own and then what I want you to see is I want you to see how quickly can you make this thing blank before you can't see it anymore and so what I want you to do is just go in and play around with this sleep number and then see at some point you are making it blink so fast that you can no longer perceive on off on off all you can perceive is you can perceive that it seems to be dim okay it seems to be dimmer but what is the uh I guess what I would say is what is the lowest number that you can use for the delay like is it 0.1.01 0.05 what is the lowest number that you can put in here and still perceive a blink and then what your homework assignment is is leave a comment down below of what your answer is and then I also want you guys to start posting your solutions to YouTube all right and so I want you to make a little simple screen capture or a little simple recording that is showing your code like I have up here and then showing your result and you know it can just be like a 30 second or a minute video then what I will want you to do is I will want you to leave a comment down below with a link over to your homework solution and then on your homework solution down in the description I want you to put a link back to this lesson so that people who are looking at your work can sort of see I can sort of see what you're talking about and then look down in the comments look at other people's Solutions and leave comments on their solution so what are we trying to do start developing a little bit of community in this Channel and a little bit of community in this class and you guys show each other what you're doing and look at each other Home each other's homework assignment oh okay guys I hope you are going to have as much fun taking this class as I am making it if you enjoyed this lesson give us give us a thumbs up helps us with the old YouTube juice also leave a comment down below that comment helps us with YouTube juice share this video with other people why because the world needs more people doing engineering and fewer people sitting around watching silly cat videos Paul McCarter with toptechboy.com I will talk to you guys later foreign