Programming with Raspberry Pi Pico W

Raspberry Pi Pico W LESSON 1: Write Your First Program for Absolute Beginners

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.

    Canva Logo
    Claude AI Logo
    Google Gemini Logo
    HeyGen Logo
    Hugging Face Logo
    Microsoft Logo
    OpenAI Logo
    Zapier Logo
    Canva Logo
    Claude AI Logo
    Google Gemini Logo
    HeyGen Logo
    Hugging Face Logo
    Microsoft Logo
    OpenAI Logo
    Zapier Logo

    Summary

    In this first episode of the tutorial series by Paul McWhorter, learners are introduced to writing their first program on a Raspberry Pi Pico W. With no prior experience required, participants will be guided through setting up both hardware and software necessary for programming. The lesson covers configuring the Pico W, setting up a development environment on a PC, and writing a few initial programs. Additionally, viewers will learn basic interaction with the GPIO pins, including making an LED blink. The class encourages community engagement by sharing progress and solutions.

      Highlights

      • Paul introduces a beginner-friendly series to unleash the power of the Pico W. πŸš€
      • Learners are encouraged to brew a fresh cup of coffee and get ready for hands-on programming. β˜•
      • The series uses the SunFounder Kepler kit to ensure consistent learning experiences. πŸ“¦
      • Step-by-step setup of the Pico W and PC development environment using MicroPython. πŸ–₯️
      • Write, run, and modify your first Python program, boosting confidence right away! πŸ‘¨β€πŸ’»
      • Interact with GPIO pins to control an LED, stepping into physical computing. πŸ’‘
      • Discover how to blink an LED using loops and import libraries in Python. πŸ”„
      • Join the online community by sharing your progress and learning from peers. 🌐

      Key Takeaways

      • You can start programming the Raspberry Pi Pico W with no prior experience! πŸ› οΈ
      • Setting up involves both software and hardware, ensuring your Pico W is ready to go. πŸ’»
      • Make your own LED blink using Python for a hands-on learning experience. πŸ’‘
      • Community involvement is encouraged – share your work and learn from others. 🌍
      • Learning doesn’t stop at one program – be curious and explore other possibilities! 🌟

      Overview

      In this exciting journey, Paul McWhorter takes absolute beginners through the process of programming the Raspberry Pi Pico W. The focus is on getting everyone up to speed, regardless of their background. The session starts with some necessary preparation, setting the stage for an engaging hands-on experience.

        Participants will learn how to set up a development environment on their PC, connect with their Pico W, and write initial programs with MicroPython. A delightful exercise involves making an LED blink, which adds an interactive layer to the learning process and brings the taught concepts to life.

          The tutorial doesn't just stop at the technical aspects. Paul emphasizes community building by encouraging participants to share their progress and help each other grow. This session is not only about learning to code but also about joining a community of like-minded individuals who are passionate about building and tinkering with technology.

            Chapters

            • 00:00 - 01:00: Introduction and Setup In the introduction, Paul McCarter from TopTechBoy .com begins the tutorial series on using Pico W. He invites viewers to prepare for the session by making a glass of iced black coffee, emphasizing relaxation and readiness for the exciting journey ahead.
            • 01:00 - 03:00: Prerequisites and Getting Started The chapter introduces the reader to the necessary prerequisites and how to get started with the course. It starts with a casual mention of coffee, suggesting a relaxed and inviting environment for learning. The chapter acknowledges the sponsorship of the series by Sunfounder and highlights the use of the Sunfounder Kepler Kit for Raspberry Pi Pico W in the classes. It notes that while most participants likely already have their gear, those who don't can find information in the description below.
            • 03:00 - 06:00: Unboxing and Connecting the Pico W The chapter introduces the Pico W and emphasizes the importance of working with identical hardware for ease of learning. The speaker aims to teach three main things: configuring the Pico W for programming, setting up a PC to interact with the Pico W, and additional content related to working with the device.
            • 06:00 - 08:00: Installing Micropython The chapter begins with setting the stage for writing the first four programs in under 30 minutes. The initial focus is on outlining the prerequisites required for the class. The instructor clarifies that having an advanced degree or extensive background in computer science is not necessary. The only assumptions made are a willingness to learn and engage with the course material.
            • 08:00 - 12:00: Setting Up Thonny IDE The chapter titled 'Setting Up Thonny IDE' begins with the instructor encouraging the learner by stating that no prior knowledge is needed. They emphasize that the learner just needs to pay attention and be willing to work hard. The instructor plans to guide the learner from beginner to advanced level with exciting projects. The initial step involves getting out the Pico W, indicating the beginning of the setup process.
            • 12:00 - 15:00: Writing Your First Program The chapter titled 'Writing Your First Program' begins with an instructor introducing a kit filled with electronic components. The instructor does not go through all the components in detail but mentions that the focus for the session will be on finding the 'picow', which is located on the second layer of the kit. This sets the stage for the subsequent activities related to programming with the components inside the kit.
            • 15:00 - 17:00: Interacting with GPIO Pins The chapter titled 'Interacting with GPIO Pins' begins with an introduction to electronic components, focusing on a single board computer. The initial step involves connecting the board to a computer using a USB cable.
            • 17:00 - 23:00: Using the While Loop and Sleep Function In this chapter, the speaker discusses the necessary materials, including a micro USB cable that needs to be connected to your PC, and the Raspberry Pi Pico W. The process of setting up and utilizing these items is described, presumably as part of a larger discussion about using the While Loop and Sleep Function.
            • 23:00 - 28:00: Homework and Class Community The chapter discusses the process of connecting a device to a PC via USB. It starts with the basic setup of ensuring the USB is recognized by the PC, indicated by the familiar 'dingdong' sound. The transcript suggests that the content is likely a tutorial or guide focusing on this technical setup within a classroom or group learning environment.
            • 28:00 - 29:00: Conclusion The conclusion chapter focuses on addressing a common issue where the device is not recognized as a USB drive. Initially, when the device was plugged in, it didn't show up as a USB device, indicating that it needs to be configured properly to be recognized. The key step in this process is to first unplug the device. Then, while pressing down a specific small white button on the device, plug it back in. This action helps in making the device recognizable as a USB drive for the first time.

            Raspberry Pi Pico W LESSON 1: Write Your First Program for Absolute Beginners Transcription

            • 00:00 - 00:30 hello guys this is Paul mcarter with toptechboy dcom and we're here today with episode number one in our incredible new tutorial Series where you're going to 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
            • 00:30 - 01:00 sweeteners none needed and as you're pouring your coffee I want to give a shout out to our friends over at sunfounder sunfounder is actually sponsoring this most excellent series of video tutorials and in this class we will be using the sunfounder Kepler kit for Ras 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
            • 01:00 - 01:30 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 picco 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 p w and then
            • 01:30 - 02:00 the third thing is we're going to WR 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
            • 02:00 - 02:30 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
            • 02:30 - 03:00 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 picow and for me it is on the second
            • 03:00 - 03:30 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
            • 03:30 - 04:00 one of these uh 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
            • 04:00 - 04:30 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 this PC view uh 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 dingdong but what you'll notice notice
            • 04:30 - 05:00 here is you'll noticed uh you'll noticed 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
            • 05:00 - 05:30 and giddy up what do you see that happened that time now we see the RPI uh 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 micropython 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 uh Pico W what's the good news is my PC is seeing the W and gives me uh shows it to me as
            • 05:30 - 06:00 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 micropython uh program so I am going to search on Raspberry Pi Pico micro python installation something like that and then for me the first result is the uh
            • 06:00 - 06:30 raspberry pie.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 micropython very good and then this is the drag and drop M micropython 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 sunfounder we have the ultimate chip
            • 06:30 - 07:00 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 I just come over here and that file that I just downlo down loaded I'm going to come
            • 07:00 - 07:30 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
            • 07:30 - 08:00 it got that micropython 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 micropython loaded onto the picow 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 PC that will allow us to
            • 08:00 - 08:30 download programs down into the PCO 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 th okay it is th so I will come here and what we're going to say is install
            • 08:30 - 09:00 th something like that should be good enough okay th 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 down download the 4.0.1 now if you have a more modern uh Windows operating system it probably is going to throw a warning when you try to
            • 09:00 - 09:30 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 th 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
            • 09:30 - 10:00 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
            • 10:00 - 10:30 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 dialogue box and then I'm going to say uh welcome to th okay next I accept I probably am giving away my left kidney by agreeing to that and firstborn grandchild I'll say next next and then let's go ahead and create a
            • 10:30 - 11:00 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 [Music]
            • 11:00 - 11:30 and 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 micropython environment on our picco W okay and now we should have th 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 th and there it is it pops right up
            • 11:30 - 12:00 there and so let's see if we can open up th 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
            • 12:00 - 12:30 that you click on and then it will bring these uh 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 thy to we want to connect th to the
            • 12:30 - 13:00 Rasberry 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 says micropython R Raspberry Pi Pico com 7 it's seems like that it is connected but
            • 13:00 - 13:30 you can come down here and then click on this and you can go to local Python 3 if you did that whatever you wrote in th whatever you wrote and th would run on your PC or you can come down to micropython Raspberry Pi Pico com 7 that will run it on the Pico so that is what I'm going to select now for me it was already selected but you need to make
            • 13:30 - 14:00 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 gidy up our first program hello
            • 14:00 - 14:30 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 Comm 7 down to the picw and then the picw printed hello world and that came back up through Comm 7 to the ID 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 PR program you're writing a program and
            • 14:30 - 15:00 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 gy up hello world so we wrote our first program well let's just try it 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
            • 15:00 - 15:30 a Time B and then what if I say print see like that just a very simple little program and let's run that boom 14 okay we have written our 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 micropython on the PW we have an IDE over here on
            • 15:30 - 16:00 our PC th that allows us to interact with the PW 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 picow and what we can do is we can
            • 16:00 - 16:30 programmatically interact with those pin 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 pen that I am going to be doing working with is called the
            • 16:30 - 17:00 LED pin and it is a pin that is actually connected right here to this little LED so if I turn that led pen 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 am going to work with those pens I'm going to have to import the library that works with the pin so I'm going to say from
            • 17:00 - 17:30 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 LED so I'm creating this little object called my LED and that is equal
            • 17:30 - 18:00 to that method that we just imported pin right so it's going to know what pen is because I just imported pen and then I've got to get it give it some parameters what pen 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 pin but I'm going to use that special pen which is called LED like
            • 18:00 - 18:30 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 sending sending data to it it's going to be a what an output so the way I do that is p 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 aut case is very important here so what
            • 18:30 - 19:00 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 pen the LED pen 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 Z is off so if I want to turn it on I need to
            • 19:00 - 19:30 put what here a one 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 gety 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 GPI opens okay if I can turn it off what should I also try to do I mean if I can turn it on what
            • 19:30 - 20:00 else should I try to do I should 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
            • 20:00 - 20:30 that okay and now you don't put anything inside of the parenthesis 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 onoff 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 a zero and then like that okay very good so we're making it
            • 20:30 - 21:00 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 zero my LED value one 0 one 0 one you want to somehow create a loop where you create a
            • 21:00 - 21:30 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
            • 21:30 - 22:00 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 take the object
            • 22:00 - 22:30 and make it an output one time and then whatever I put here I'm going to Loop and so 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. value is what zero 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 their breath and oh oh oh I'm sorry my LED I had a
            • 22:30 - 23:00 problem there so I will say my LED like that somebody didn't hold their breath everyone hold their breath this time and Deni 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
            • 23:00 - 23:30 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
            • 23:30 - 24:00 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 the library import the method which is sleep like that okay from time import sleep and I don't remember remember if sleep is uppercase
            • 24:00 - 24:30 or not maybe it's 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 1 second I'm going to turn it off and I'm going to wait one second and now let's see
            • 24:30 - 25:00 what happens okay watch ah gidy 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 0.1 and let's go off for point1 let's see what happens there you guys keep your eyes on the uh on the blinking LED there come in and shoot it
            • 25:00 - 25:30 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
            • 25:30 - 26:00 you see how we can customize how this thing is behaving man it's just like the first lesson and you're already programming GPI pens 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
            • 26:00 - 26:30 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
            • 26:30 - 27:00 familiar enough with it that you're not just going back and recopying 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 blink 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 can no longer perceive on off on off all you can
            • 27:00 - 27:30 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 0.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
            • 27:30 - 28:00 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 uh 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
            • 28:00 - 28:30 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 uh 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 Solutions 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
            • 28:30 - 29:00 and look at each other Home each other's homework assignment 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 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
            • 29:00 - 29:30 Paul mcarter with toptechboy do.com I will talk to you guys later [Music]