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):
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 “” 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.


from machine import Pin, Timer

inbuiltLed = 25

led = Pin(inbuiltLed, Pin.OUT)

timer = Timer()

def ledblink(timer):


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



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 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.

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.