Thonny, Installing MicroPython & Hello World | Raspberry Pi Pico Workshop: Chapter 1.6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right let's finally set up our picco and run our very first bit of code now there are many different coding languages out there but for this course we will be using the micropython language it is a very popular language that is a variant of another popular language called python micropython is just a cut down and more lightweight version of it designed to run on micro controllers like our Pico here we are going to be using a program called thuny which is what we will be using to program our Pico with so if you don't already have that installed we have a link in the description or there's a link on the course site or you can just head over to thon.org once it's finished installing we're going to open up Sony and you should be looking at something like this now we're going to install micropython on the Pico so if you've already got micropython on your pico set up you can skip this phase you can check if micropython is installed by plugging in your Pico and then in thy in the bottom right you should be able to see micropython Raspberry Pi peaker as a selectable option that means it is installed so to install micropython we'll first start by holding down the boot select button and then we'll plug our USB into the Pico you can let go of it once it's plugged in then we're going to go back into thy and we're going to hit run and then select configure interpreter under this field here we're going to make sure that we have Micro python Raspberry Pi Pico selected and then we're going to click install or update micro python under variant we're going to select either PCO or PCO W pwh depending on variant of the board you have we've got a PCO wh so we're just going to select this one and then we're going to leave the version alone and just click install it shouldn't take too long to download and install micropython onto the Pico and once it's done your pico is all set up ready to go once you finished installing in this previous window we're going to hit okay and then we're going to reopen it again you should now see that this port option here has selected the board it should automatically do that if not you can go down into the bottom here and select micropython Raspberry Pi Pico and and you'll see Which comp Port it is connected to selecting the right serial Port is very important as we are telling the computer which serial connection the Pico is if you don't select the right comport you can't run any code you've written in thony on your pico it should be noted that my Pico is plugged into comport 3 but it might be different on your system and it most likely will so if we take a look at TH we have two sections here we've got this top section here which is the editor this is where we will be writing most of our mic python code we also have this bottom section here which is called the shell and this is very similar to the editor but it works in a slightly different way you can think of the top editor as kind of a piece of paper that you write out all your code onto and then you send it to the peod and then it executes all that code the shell is like talking to the peod directly line by line we send it a command it reads it and it replies immediately we like to call this repple or read evaluate print Loop the shell here is used maybe if you want to try some code on the fly but most of the time it's the place where we can see the Pico replying back to us when we ask it to we might ask it to tell us what sensor data it is seeing or what it is currently doing but we'll get into that later this is a good opportunity to introduce our first piece of code the print function to try it out we're going to write in the shell print and then some brackets on the end now this print function is going to print whatever we put in the brackets but to get it to print a normal sentence we'll need to put quotation marks in like so in these quotation marks you can type anything so we're just going to put in hello world and if you hit enter the peer should reply back with whatever you put in the quotation marks congratulations you have just written your first piece of code so what's happening here is that when we hit enter the print command gets sent from thony to the Pico and the Pico reads it it knows what the print command does and so it follows that order and prints back whatever was in the print command back to thony we can also write that same code in the editor and we can kind of keep it there and when we want to send it to the picco we can hit this big green button at the top here and as you can see it replies back exactly the same but the advantage of the editor here is that you could then put in another line with something else this is the second line wow and if you run it again the Pico will return with both lines and this is why we like using the editor because it lets us write out a big long bit of code and then we can send it to the Pico this specific formatting we have to use with the brackets and the quotation marks is called syntax and it is kind of like grammar but for coding while in day-to-day conversations you don't need to use perfect grammar for somebody to understand you it is not the same when it comes to coding you need to use correct grammar or syntax otherwise the Pico won't understand what you're trying to tell it don't worry too much about that though syntax is easy to learn and it's one of the many reasons we're using micropython because it is simple clean and easy to understand it's got very simple syntax compared to other languages I'll end this video by showing you some sample code don't worry about understanding this or how it works I'm just showing you some important syntax before we begin first of all each line of code here is like a command that we're going to send to the picco I've got kind of these spaces between some of these lines these spaces they they don't really do anything they don't slow down the Pico it just ignores the spaces that you put in there the reason we use these spaces is to make the code more readable to humans like us if I go through and I delete these spaces this is the exact same code as before but it might be a bit more hard to read to us humans so we like to put spacing in there but it is personal preference another important thing is comments if you look in the code here we have some hashtags followed by some gray out text and these are comments the PCO will also ignore anything that you put after the hashtag and we can use this as an opportunity to comment on our code to make it more understandable for humans if you look at this line you probably have no clue what's going on but thankfully somebody has commented what this line does it sets up pin 16 which is connected to the LED I'll quickly add another comment here just by putting in hashtag followed by putting in whatever text so I say this line puts the Pico to sleep for two seconds and it is a very good idea to comment your code as it might help someone else or future you in figuring out how this code works you might come back to it later and have no idea what is going on and these comments will be very helpful
Info
Channel: Core Electronics
Views: 1,101
Rating: undefined out of 5
Keywords: tutorial, DIY, circuit, learn, diy projects, upload, project, beginner, beginner friendly, how to, explanation, guide, help, STEM, Pico, MicroPython, Arduino, Microcontroller, Pico Projects, Raspberry Pi, Raspberry Pi Pico, Course, Learn, Pico Course, Microcontroller Course, Learn Microcontrollers, Pico WH, Pico LED Blink, Pico Beginner, Beginner course, Beginner friendly course, Starter course, Pico Hello World, Hello World, Pico Print, REPL, Thonny, Thonny Pico, Install Micropython
Id: 1QqHAwCkQLU
Channel Id: undefined
Length: 6min 57sec (417 seconds)
Published: Wed Jan 24 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.