Getting Started with The Raspberry Pi Pico – Blinking a LED on Pico Using MicroPython

Raspberry Pi Pico Tutorial

Hello everyone, in this tutorial, we are going to perform a simple LED blinking program on the Raspberry Pi Pico. Raspberry Pi Pico is based on the RP4060 microcontroller chip which is the first ever microcontroller family class by Raspberry Pi foundation. If you are searching for the low cost development board with high-performance features, then the Pico board is the best choice. We can program this Pico board in various methods as it supports basic debugging tools and libraries for C/C++ Development and Micropython Environment. Here I am going to discuss on how to program the Pico board with Micropython framework. As this is going to be the first step to program the Raspberry pi Pico, let me discuss the basic features of the Pico board.

Respberry Pi Pico Board

 

Top View of the Pico Board

Raspberry Pi PICO Overview

Let’s see what we have on the Raspberry Pi Pico board. Raspberry Pi Pico is a 40 pin 21x51 ‘DIP’ style 1mm thick PCB with 0.1" through-hole pins also with edge castellation. It has 3-pin ARM Serial Wire Debug (SWD) that is marked in light brown circle in the picture above, the yellow circle represents the On-board USB1.1. If you look at the top, you will find the RP2040 microcontroller chip is placed at the center of the board that is marked in pink circle. It has an in-built LED alongside to the USB-Connector. The blue colored circle is representing the built-in Led which is internally connected to the GPIO25 pin. The red circled button is a white push button that can be used as a boot loader button.

 

Bottom View of the Pico Board

Raspberry Pi Pico Bottom View

Let’s see what we have at the bottom side of the Pico PCB board in the above image. The square pads are generally used as the Test Points (TP1 – TP6) which can be accessed if required, for example if using as a surface mount module. TP1, TP2 and TP3 can be used to access the USB signals instead of using the micro-USB port. TP6 can be used to drive the system into mass-storage USB programming mode (by shorting it low at power-up). Note that TP4 is not intended to be used externally, and TP5 is not really recommended to be used as it will only swing from 0V to the LED forward voltage.

 

Features of the Raspberry Pi Pico Development Board

Raspberry Pi Pico is a low-cost, high-performance microcontroller board with multi-function GPIO pins. Following are the key features of the Raspberry Pi Pico board.

  • Raspberry Pi Pico has 26 multi-function GPIO pins and 8 Programmable Input/output (PIO) state machines for custom peripheral support.
  • Pico board consists of 2 SPI, 2 I2C, 2 UART, 3 12-bit ADC and 16 controllable PWM channels.
  • 264KB of SRAM, and 2MB of on-board Flash Memory.
  • Low-power sleep and dormant modes.
  • Built-in Temperature Sensor, Accurate Clock and Timer on-chip.
  • The RP2040 microcontroller has cortex m0+ at up to 133MHz. the presence of the On-chip PLL allows us to vary the core frequency.

 

Raspberry Pi Pico Pinout Configuration

The pin description of the Raspberry Pi Pico has been displayed in the below picture. The Pico has 26 GPIO pins which are labeled as Green in the picture below.

Raspberry Pi Pico Pinout

 

Connecting LED with Raspberry PI Pico

 The following schematic diagram can be referring to connect an LED with Raspberry Pi Pico. I connected the LED to the GPIO 1 or Pin number 2 and the GND pin is connected to the Ground.

Raspberry Pi Pico and LED Connection

 

Installation of Thonny IDE and MicroPython Framework On Raspberry Pi Pico

At first, you need to install the Thonny IDE to program the Raspberry Pi Pico. When the installation has been completed we need to perform some basic setup of the Thonny IDE. The following Picture is a snapshot of the Thonny IDE. In the picture you can see the red circled section has the basic debugging tools. The green section is for selecting the device or python version we are using. This can be called as interpreter selection menu.

Thonny IDE

 

Now you need to follow the below steps to install the Micropython framework on Raspberry Pi Pico. On the Pico board you can see a White Push Button that is marked as “BOOTSEL”.

Raspberry Pi Pico BOOTSEL Button

The BOOTSEL button on my board is shown above highlighted red. Press the button and hold it until you connect the Pico board to the PC or Laptop via USB port.  When you will connect the Pico board you can see under the Interpreter selection menu “MicroPython (Raspberry Pi Pico)”. Click on this and follow the installation as per instructed on the window.

Raspberry Pi Pico Micropython framework Installation

Now you can refer the following code to blink an LED of the Raspberry Pi Pico. The code is very simple to understand. We have a machine library in MicroPython which includes all the basics built-in libraries. The Pin() function can be called to make an object. In my case I made an object by using “led” in the code below. I passed two parameters into the Pin() function that is Led and Pin.OUT where the Led is representing the GPIO pin and the Pin.OUT is used to set that GPIO pin as an OUTPUT pin respectively. It can be set to IN or OUT. The Timer() function allows us to use the built-in timer on the Raspberry Pi Pico.

from machine import Pin, Timer

Led = 0
led = Pin(Led, Pin.OUT)
timer = Timer()

 

Now, we need to create a function ledblink() to provide the timer. Actually the Timer() has an in-built method named as init(). In this init() method, we can callback a function with some delay. This delay can be provided as “PERIODIC” by using the “mode” parameter. The “freq” parameter is used to determine the frequency delay of each callback. The led.toggle() is used to change the state of the led from HIGH to LOW or LOW to HIGH.

def ledblink(timer):
    led.toggle()
timer.init(freq=2.5, mode=Timer.PERIODIC, callback=ledblink)

 

Now, let’s save the code. When you save the code, it will show you a popup as shown below, asking where you want to save the file. You need to select Raspberry Pi Pico and then name the file as “main.py” and click on save. By doing this procedure, the Raspberry Pi Pico will run the program when it is power up.

Raspberry Pi Pico Tutorial

 

Running our first Blink Program on Pico

So, we have finished our first Raspberry Pi Pico tutorial. In the following video, you can find more explanation on how to run the code on the raspberry pi pico.

Code

from machine import Pin, Timer

inbuiltLed = 25

led = Pin(inbuiltLed, Pin.OUT)

timer = Timer()

def ledblink(timer):

    led.toggle()

timer.init(freq=2.5, mode=Timer.PERIODIC, callback=ledblink)

Video

54 Comments

I wanted to compose you that very little note to finally thank you so much yet again for the remarkable opinions you've provided above. This has been quite pretty open-handed with people like you to allow easily all some people would've sold as an e-book to make some dough for their own end, most importantly considering that you could have tried it if you ever decided. Those tricks additionally acted like a easy way to understand that other people have the identical fervor much like my very own to learn a whole lot more with reference to this matter. I believe there are many more enjoyable periods ahead for individuals who look into your blog.

I simply wanted to post a simple message so as to say thanks to you for the unique strategies you are writing here. My extended internet look up has finally been recognized with high-quality concept to talk about with my friends and classmates. I would assert that we visitors actually are really lucky to dwell in a magnificent community with so many marvellous professionals with interesting suggestions. I feel somewhat blessed to have encountered your website and look forward to plenty of more excellent minutes reading here. Thank you once more for a lot of things.

I together with my guys were found to be analyzing the great helpful tips found on the website and immediately I had a terrible suspicion I never thanked the site owner for those tips. All of the young boys are actually as a result warmed to learn all of them and have now in actuality been using these things. Appreciate your really being really accommodating and also for deciding on certain magnificent subject areas millions of individuals are really desirous to understand about. My very own honest regret for not expressing appreciation to sooner.

Thank you so much for giving everyone remarkably splendid chance to check tips from this website. It can be very pleasurable and full of fun for me personally and my office colleagues to visit your site at minimum 3 times every week to read the new stuff you will have. Of course, I am usually contented for the awesome principles you serve. Selected 2 points in this article are in truth the most suitable we've ever had.

My spouse and i have been really fulfilled that Peter managed to finish off his preliminary research from the ideas he received from your very own site. It is now and again perplexing just to find yourself freely giving tricks which often others could have been making money from. And we consider we've got the blog owner to thank for that. All of the explanations you've made, the simple site menu, the relationships you give support to engender - it's got mostly extraordinary, and it's facilitating our son in addition to the family understand this situation is fun, and that's unbelievably serious. Thanks for the whole thing!

A lot of thanks for each of your efforts on this website. Debby take interest in working on investigations and it's really easy to understand why. My partner and i learn all relating to the dynamic manner you offer vital suggestions on this web site and as well as recommend response from visitors about this concern plus my princess is certainly being taught so much. Take pleasure in the remaining portion of the new year. You are always carrying out a splendid job.

whoah this blog is great i really like reading your posts. Stay up the great work! You already know, many persons are searching around for this info, you can help them greatly. |

Thank you a lot for giving everyone remarkably memorable opportunity to read from this website. It can be very great and also jam-packed with amusement for me personally and my office acquaintances to visit your website at a minimum three times per week to see the latest secrets you will have. And indeed, I am actually astounded with your magnificent tricks served by you. Certain 4 tips in this posting are unquestionably the most impressive I have had.

I precisely desired to thank you so much all over again. I'm not certain the things I would've sorted out without those basics contributed by you relating to this subject. It was a real difficult case in my view, however , seeing the professional manner you dealt with the issue forced me to cry with delight. I will be grateful for the information and as well , have high hopes you are aware of an amazing job your are getting into instructing men and women with the aid of your web site. I'm certain you have never got to know all of us.

I wish to get across my affection for your generosity giving support to those people who really need help with this particular subject matter. Your real dedication to passing the message throughout came to be extraordinarily valuable and have enabled professionals just like me to reach their dreams. Your personal valuable report indicates so much a person like me and somewhat more to my office colleagues. With thanks; from each one of us.

I simply wished to say thanks again. I do not know the things that I would've carried out without the thoughts provided by you concerning such field. Previously it was the frightful condition in my view, nevertheless witnessing a new specialized mode you treated that forced me to weep with contentment. I'm just happier for your support and as well , wish you really know what a powerful job you're getting into training people today through the use of your webblog. Most probably you've never encountered any of us.

I together with my buddies appeared to be following the great guidelines located on the website and so immediately got a horrible suspicion I never thanked the web site owner for those secrets. All of the ladies came very interested to read all of them and already have absolutely been using these things. We appreciate you truly being simply accommodating and also for getting varieties of quality themes millions of individuals are really wanting to be aware of. Our own honest regret for not expressing appreciation to you sooner.

Thanks for your whole work on this blog. My aunt takes pleasure in managing research and it's obvious why. Most of us notice all about the dynamic medium you convey worthwhile guidelines by means of your blog and as well foster participation from some others on that matter so our own simple princess is studying a lot. Have fun with the rest of the year. You're the one doing a superb job.

My wife and i were very peaceful when John could finish off his researching through the ideas he received when using the site. It is now and again perplexing to just find yourself giving away tactics that other folks may have been trying to sell. And we also know we've got the blog owner to give thanks to because of that. Those explanations you made, the straightforward site navigation, the relationships your site give support to promote - it's many overwhelming, and it's really making our son and our family reason why the idea is excellent, and that's pretty indispensable. Thank you for the whole lot!

I'm commenting to make you understand of the brilliant experience my friend's child developed studying your web site. She learned some details, including what it's like to have a great giving nature to get other individuals easily know precisely certain hard to do matters. You undoubtedly surpassed our expectations. Many thanks for presenting those valuable, trusted, informative and even easy guidance on the topic to Jane.

I must point out my love for your generosity in support of people that require assistance with the matter. Your very own dedication to passing the message along appeared to be incredibly interesting and have all the time enabled some individuals like me to attain their pursuits. Your new warm and helpful hints and tips can mean much a person like me and still more to my peers. Warm regards; from each one of us.

My wife and i felt really glad Chris could deal with his analysis via the ideas he received in your web page. It's not at all simplistic just to happen to be making a gift of hints which usually men and women may have been making money from. And we recognize we now have the writer to be grateful to because of that. The type of illustrations you've made, the easy website menu, the friendships you will make it easier to engender - it's got mostly exceptional, and it's making our son in addition to our family imagine that that theme is awesome, which is certainly extraordinarily indispensable. Thanks for all!

A lot of thanks for all your valuable efforts on this web page. My mom take interest in conducting investigation and it is easy to see why. We know all relating to the powerful method you deliver great suggestions through your web site and as well as recommend participation from other ones on this theme and my simple princess is discovering a lot of things. Enjoy the remaining portion of the year. You're the one conducting a wonderful job.

I simply desired to say thanks yet again. I'm not certain the things I might have created in the absence of the type of tips shown by you relating to such concern. Previously it was a very daunting dilemma in my view, nevertheless spending time with the skilled mode you treated that forced me to weep for fulfillment. I will be thankful for your information and then wish you are aware of a great job you have been putting in training many people by way of your websites. I'm certain you've never come across any of us.

I precisely desired to thank you so much all over again. I am not sure what I would have tried in the absence of these techniques discussed by you relating to such problem. It was a very scary matter in my opinion, but encountering the well-written style you managed that took me to jump over delight. I'm just thankful for your assistance and thus hope that you recognize what an amazing job you're accomplishing instructing the others with the aid of a site. More than likely you haven't got to know all of us.

My wife and i ended up being quite lucky John managed to deal with his investigation through your ideas he obtained from your web pages. It's not at all simplistic just to possibly be giving for free solutions which often people could have been selling. So we figure out we have got the blog owner to be grateful to for this. The main illustrations you've made, the easy web site navigation, the relationships you can help to create - it's many unbelievable, and it's really helping our son in addition to our family know that that theme is interesting, and that's rather essential. Thanks for all the pieces!

I simply wished to appreciate you yet again. I do not know the things I would've sorted out without the entire tips and hints revealed by you over such area. It absolutely was a frightful setting for me, however , viewing the very expert tactic you dealt with that forced me to leap for happiness. Extremely happier for this service as well as hope you find out what a great job you are getting into instructing the others using a site. Most probably you've never encountered any of us.

My wife and i ended up being quite fulfilled when John could finish off his reports using the ideas he made in your web page. It is now and again perplexing to simply be giving for free helpful hints which usually some others have been selling. We really understand we need the blog owner to be grateful to for this. The main illustrations you've made, the straightforward blog navigation, the friendships you can aid to engender - it is everything fantastic, and it is letting our son and the family recognize that the content is pleasurable, which is exceptionally vital. Thank you for the whole lot!

I have to express my thanks to you for bailing me out of this particular difficulty. As a result of checking throughout the the net and seeing views that were not pleasant, I figured my entire life was over. Living minus the approaches to the issues you've solved by way of this blog post is a critical case, and the kind which could have in a negative way damaged my entire career if I had not noticed your blog. Your own personal natural talent and kindness in taking care of a lot of things was tremendous. I am not sure what I would've done if I had not discovered such a step like this. I am able to at this time look ahead to my future. Thank you very much for this reliable and effective help. I will not hesitate to refer the website to anybody who will need assistance about this problem.

I happen to be writing to let you understand what a really good experience my cousin's girl encountered viewing your web page. She mastered too many details, which included what it is like to have an awesome helping character to let other folks completely know precisely a variety of very confusing subject areas. You truly exceeded my desires. Thanks for offering the good, healthy, explanatory and easy tips on this topic to Evelyn.

Thanks a lot for giving everyone such a splendid chance to read in detail from this web site. It is usually very pleasurable and also jam-packed with amusement for me personally and my office fellow workers to visit your web site at minimum three times in one week to read the newest items you will have. And lastly, I'm also usually fascinated considering the powerful thoughts you serve. Certain 4 points in this article are unequivocally the most beneficial I've had.

My spouse and i were now glad when Peter could round up his researching by way of the precious recommendations he was given from your web site. It's not at all simplistic to simply possibly be giving for free steps that some people might have been trying to sell. So we recognize we have got the blog owner to thank for this. The entire illustrations you made, the easy blog menu, the relationships you can give support to foster - it is many superb, and it's really helping our son and us know that this topic is interesting, and that's incredibly vital. Many thanks for everything!

I'm also commenting to make you understand of the exceptional encounter our child had studying the blog. She figured out many details, most notably how it is like to possess an excellent teaching character to get many others without hassle learn some specialized subject areas. You actually did more than our own expected results. Thanks for giving these practical, trusted, informative not to mention cool guidance on your topic to Gloria.

Thanks a lot for providing individuals with an extraordinarily memorable possiblity to check tips from this web site. It is often so superb plus packed with fun for me personally and my office mates to visit your website really 3 times per week to see the fresh guides you will have. And lastly, I am at all times impressed with the perfect tricks you serve. Selected 3 areas on this page are in fact the simplest we've had.

I not to mention my buddies ended up going through the excellent tips on your web blog and so before long developed an awful feeling I had not expressed respect to the site owner for those strategies. The people had been for that reason very interested to study all of them and now have in actuality been having fun with those things. Appreciate your getting really kind and for choosing this sort of fabulous guides millions of individuals are really eager to learn about. My personal sincere apologies for not expressing appreciation to you earlier.

My spouse and i were happy Emmanuel managed to complete his survey via the precious recommendations he acquired when using the web page. It's not at all simplistic to simply happen to be giving out procedures which often men and women have been trying to sell. Therefore we recognize we have got the writer to be grateful to for that. The most important explanations you made, the simple website menu, the relationships your site aid to create - it's all great, and it is assisting our son in addition to our family reckon that this topic is enjoyable, which is certainly unbelievably essential. Thank you for all!

My husband and i felt very joyous Ervin managed to round up his investigation from the ideas he gained from your site. It's not at all simplistic to simply possibly be releasing instructions which a number of people could have been trying to sell. And we figure out we have the blog owner to be grateful to for this. The most important illustrations you've made, the straightforward web site navigation, the friendships you help to engender - it's got most astonishing, and it's really making our son in addition to us believe that the article is amusing, and that's seriously fundamental. Thank you for all!

I am glad for commenting to let you be aware of what a fantastic discovery our girl went through reading through your blog. She figured out numerous pieces, which included what it is like to have a very effective giving spirit to make the rest completely understand a variety of complex subject areas. You undoubtedly did more than people's expectations. Thanks for showing the insightful, dependable, revealing as well as easy tips about the topic to Julie.

I am also commenting to let you understand what a outstanding experience my child developed viewing your webblog. She learned several things, with the inclusion of what it is like to possess a marvelous helping character to get the mediocre ones quite simply learn about several complex matters. You truly surpassed visitors' expected results. Many thanks for churning out such insightful, trustworthy, edifying and unique thoughts on that topic to Julie.

Your breadboard picture shows led connected between GP1 and GND, while your code uses GP0 to drive the Led. So either the code is wrong or your breadboard has wrong position for the resistor.

I intended to write you that little bit of note just to thank you once again considering the striking tips you have shown above. This has been quite surprisingly generous with you to offer freely precisely what a number of us would have made available as an e-book to help with making some money for their own end, and in particular since you might have tried it if you ever considered necessary. Those tactics in addition served to become a easy way to be certain that many people have a similar dream much like my personal own to see whole lot more on the topic of this issue. I think there are lots of more pleasurable opportunities in the future for people who see your blog post.

I wish to express thanks to you just for bailing me out of such a difficulty. Just after looking out throughout the internet and obtaining proposals which are not productive, I assumed my life was gone. Being alive without the solutions to the issues you've solved by way of this post is a critical case, as well as ones that could have in a wrong way affected my entire career if I hadn't come across your website. Your main expertise and kindness in handling all things was important. I don't know what I would've done if I hadn't discovered such a solution like this. I am able to at this point relish my future. Thanks very much for the skilled and effective guide. I won't be reluctant to endorse your web sites to any individual who wants and needs tips about this subject matter.

|When it comes to hair accessories, there are millions of options available. Hair accessories are things like hair bows, headbands and ponytail holders, but they also include hair extensions. An arsenal of hair accessories makes it easier to look great every day--no more bad hair days! The real benefit here is that you can make a quick little accessory change and completely change your entire look! You can go from a sporty look with your hair pulled back to a classier look with one accessory change. If you're going out for the night, pick a headband that goes with the outfit you're wearing.

I must show some thanks to you just for rescuing me from this type of problem. Just after surfing through the world wide web and seeing basics which were not powerful, I figured my life was gone. Being alive devoid of the strategies to the problems you've resolved all through your article is a serious case, and the ones that could have badly affected my entire career if I hadn't encountered your web page. Your main mastery and kindness in touching all the things was vital. I am not sure what I would have done if I hadn't come across such a point like this. I am able to at this time relish my future. Thanks for your time very much for your expert and result oriented guide. I won't hesitate to recommend your web blog to anybody who ought to have guidance about this area.

I intended to draft you that little bit of word to give many thanks once again relating to the spectacular strategies you have featured in this article. It has been so extremely generous with people like you to allow openly what some people would've marketed for an e-book in making some dough on their own, and in particular given that you could have tried it if you ever desired. The basics also served to become easy way to recognize that some people have the identical dream really like my personal own to find out many more concerning this matter. I'm sure there are several more pleasurable instances in the future for individuals who read carefully your blog.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.