How to Set Up and Use MicroPython on the Raspberry Pi Pico

MicroPython is like Python but teenier.
Ash Ash (362)

Ready to play with your new Raspberry Pi Pico? Not so fast! You'll need to set up some software on a separate machine before you can start programming your new microcontroller. Makers have a couple of options to choose from when using the Pico including both MicroPython and C.

As the title of this guide suggests, we'll be covering how to get started with MicroPython. However, you should be aware that this is just one method you can choose when programming the Pico.

What is the Raspberry Pi Pico?

If this is all new, you might be wondering what the Raspberry Pi Pico even is. In short, it's the latest model of Raspberry Pi and first official microcontroller from the Raspberry Pi Foundation. Read more about the Pico and its specs in our Raspberry Pi Pico Master Guide.

Vilros Pico Starter KitVilros Pico Starter Kit ×1

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

New to microcontrollers? You might be wondering what MicroPython exactly is. This is a special edition of Python 3 designed to run on small, compact microcontroller systems like the Raspberry Pi Pico.

It's great for programming simple functions and even somewhat complex ones—especially if you're already familiar with Python. Read more about it on the official MicroPython website.

Make sure your Pico is ready for whatever project you have in mind. Gather any modules, jumper wires, or tools you might need for your Raspberry Pi Pico project. Here are a few questions to make sure you're prepared to get started.

  • Do you need any accessories or additional modules?
  • Will you need a breadboard for prototyping?
  • Have you soldered any headers into place?

To use MicroPython and program the Pico with it, we'll be using an Integrated Development Environment (IDE) called Thonny. Thankfully, the latest edition has been updated to include support for the Raspberry Pi Pico which saves us a lot of hassle!

Visit the official Thonny website and download the latest edition for your operating system. Versions are available for Mac, Windows, and Linux machines.

Run the installer and make sure Thonny can launch without any issues when it's done.

Install MicroPython Pico
  • Connect your Raspberry Pi Pico to the computer with a micro USB cable while holding the button on the Pico. Your OS should recognize the Pico as a connected device.
  • If you haven't already, launch Thonny.

Thonny may not recognize the Pico immediately. Make sure the IDE is configured for using MicroPython with the Raspberry Pi Pico using these steps:

  • Open Tools and choose the Interpreter tab.
  • Under the drop-down labeled "Which interpreter or device should Thonny use for running your code?", choose "MicroPython (Raspberry Pi Pico).
  • Set the Port to "< Try to detect port automatically >".
  • Click OK.

When your Pico is first detected, Thonny will give you an option to install MicroPython. Click Install and wait for the process to finish.

Program Pico with MicroPython

The Raspberry Pi Pico can store up to 2MB of data. MicroPython is super flexible in this environment. It doesn't take up much space and is easily stored on the Pico alongside any code you want to use. With Thonny, we can store programs on the Pico or run commands in real-time using the Shell window.

How to store a program

Enter your MicroPython script into the top window in the Thonny application. When you try to save or run it, you will be prompted with a question as to where you want the script to be saved. Specify that you want to use the MicroPython Device. This will ensure the script is saved to the Pico.

Below is a sample script that will toggle the onboard LED.

from machine import Pin
led = Pin(25, Pin.OUT)


How to run a program using Shell

It's also possible to run commands using Thonny's Shell window. If you don't see it, click View then Shell. If you run the following script

print ("Hi there.")

You will receive a response in the Shell window with the string Hi there.

Once you've got a grasp on how MicroPython is installed and programmed on the Pico, all you need is a project to develop! The Pico is a great microcontroller option for projects that need centralized command for a few components at a time. While a Raspberry Pi runs a full-blown OS, these modules are assigned simple tasks and use much less power.

Take your time deciding what components will work best in your project and grab a breadboard for some prototypes. Congratulations! You're ready to get started with MicroPython on the Raspberry Pi Pico.

You need these goodies!
Ash Ash (362)

We're big fans of the new Raspberry Pi Pico microcontroller and can't wait to see what new accessories and projects come out of its development.