---
agent:
  instructions: "Use this search API to find relevant content across this site (products with prices and stock, collections, guides, articles, courses, help and pages) with keywords or natural-language queries, instead of crawling individual pages. Replace {query} with your URL-encoded query. Results are returned in Markdown."
  endpoint: "https://piaustralia.com.au/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Getting started with MicroPython on Raspberry Pi Pico

Put MicroPython on a Pico, Pico W, Pico 2 or Pico 2 W, talk to it from Thonny, blink the onboard LED and make your program start every time the board powers up.

MicroPython is a compact Python 3 that runs directly on the Pico's chip. There's no operating system to install: you copy a single firmware file onto the board, and from then on it gives you a Python prompt over its USB cable.

## What you need

- A Pico-series board
- A micro USB cable that carries data (some cheap cables only carry power, and the board never shows up)
- A computer running Windows, macOS, Linux or Raspberry Pi OS

## Pick the right firmware

Each board needs its own build of MicroPython. Get the one that matches your board from the MicroPython download pages:

| Board | Chip | Download page |
|---|---|---|
| Pico, Pico H | RP2040 | [RPI_PICO](https://micropython.org/download/RPI_PICO/) |
| Pico W, Pico WH | RP2040 + wireless | [RPI_PICO_W](https://micropython.org/download/RPI_PICO_W/) |
| Pico 2 | RP2350 | [RPI_PICO2](https://micropython.org/download/RPI_PICO2/) |
| Pico 2 W, Pico 2 WH | RP2350 + wireless | [RPI_PICO2_W](https://micropython.org/download/RPI_PICO2_W/) |

The H versions are the same boards with headers fitted, so they take the same firmware. On each page, download the release marked "latest": a `.uf2` file named after the board and version, such as `RPI_PICO_W-20260824-v1.29.0.uf2`. The Pico 2 and Pico 2 W pages also offer a `RISCV` build; unless you specifically want to run the RP2350's RISC-V cores, take the standard one.

## Install it with BOOTSEL

1. Unplug the Pico from USB, and from anything else that might be powering it through VSYS or VBUS.
2. Hold down the **BOOTSEL** button (beside the USB socket) and plug the USB cable in.
3. Let go once a new drive appears on your computer: **RPI-RP2** for an RP2040 board, **RP2350** for a Pico 2.
4. Drag the `.uf2` file onto that drive.

After a few seconds the drive vanishes by itself. That's the board rebooting into MicroPython, not an error. Nothing visible happens next: MicroPython simply waits for instructions.

BOOTSEL mode lives in the chip's read-only memory, so whatever you flash, holding the button while you plug in will always get you back here. You can't brick a Pico from software. Once MicroPython is running, typing `machine.bootloader()` at the prompt does the same thing without the button.

## Set up Thonny

Thonny is a free Python editor for beginners that knows how to talk to a Pico.

- **Windows and macOS:** download the installer from thonny.org. It includes its own Python, so there's nothing else to set up.
- **Linux:** thonny.org has a one-line installer, or use your distribution's package.
- **Raspberry Pi OS:** look under Programming in the menu, and if it isn't there, run `sudo apt install thonny`.

Plug the Pico in normally (no BOOTSEL this time), then:

1. Click the interpreter name in the bottom-right corner of Thonny's window.
2. Choose **MicroPython (Raspberry Pi Pico)**. On an older Thonny without that entry, **MicroPython (generic)** also works.
3. The Shell panel at the bottom should show a MicroPython banner and a `>>>` prompt.

Thonny can also install the firmware for you: the interpreter settings (under the Run menu) have a button for installing or updating MicroPython.

## Try the REPL

Anything you type at the `>>>` prompt runs on the Pico straight away. Switch the onboard LED on and off:

```python
>>> from machine import Pin
>>> led = Pin("LED", Pin.OUT)
>>> led.on()
>>> led.off()
```

Two keys worth knowing in the Shell: **Ctrl-C** interrupts a running program, and **Ctrl-D** soft-reboots MicroPython, printing the version and board it was built for.

## Why the LED is called "LED"

| Board | Onboard LED connects to |
|---|---|
| Pico, Pico 2 | GPIO 25 |
| Pico W, Pico 2 W | the wireless chip, not a GPIO pin |

So `Pin(25)` only lights the LED on the non-wireless boards. The name `"LED"` works on all four, provided you flashed the matching firmware. If the LED stays dark on a W board, you've probably loaded the plain Pico build. To check which build is running:

```python
>>> import sys
>>> sys.implementation._machine
'Raspberry Pi Pico W with RP2040'
```

## Blink it

Type this into Thonny's main editor:

```python
from machine import Pin
import time

led = Pin("LED", Pin.OUT)

while True:
    led.toggle()
    time.sleep(0.5)
```

Click **Run**. Thonny asks where to save the file: choose the Pico (listed as "Raspberry Pi Pico" or "MicroPython device") and call it `blink.py`. The LED flips on and off every half second. Click **Stop** to end it.

## Run it at power-up

MicroPython looks for a file called `main.py` on the board each time it starts, and runs it if it's there. Use **File → Save as**, pick the Pico, and save your program as `main.py`. Now it runs whenever the board gets power, from a computer, a USB charger or a battery, with no computer needed.

To test without unplugging, press Ctrl-D in the Shell. To stop a program starting automatically, open **View → Files**, which shows the Pico's storage beside your computer's, and rename or delete `main.py`.

## Starting from scratch

If you want a completely clean board, Raspberry Pi publishes a `nuke_universal.uf2` file (in the releases of its pico-sdk-prebuilts repository on GitHub). Copy it across in BOOTSEL mode and it erases the whole flash, MicroPython and your files included. Then install the firmware again as above.

## Parts in this guide

- [Raspberry Pi Pico 2W](https://piaustralia.com.au/products/raspberry-pi-pico-2w.md)
- [Raspberry Pi Pico 2 - RP2350](https://piaustralia.com.au/products/raspberry-pi-pico-2-rp2350.md)
- [Raspberry Pi Pico W](https://piaustralia.com.au/products/raspberry-pi-pico-w.md)
- [Raspberry Pi Pico](https://piaustralia.com.au/products/raspberry-pi-pico.md)
- [Get Started with MicroPython on Raspberry Pi Pico, 2nd Edition](https://piaustralia.com.au/products/get-started-with-micropython-on-raspberry-pi-pico-2nd-edition.md)
- [Pico USB Patterned Fabric Cable - A/MicroB 1m](https://piaustralia.com.au/products/usb-patterned-fabric-cable-a-microb-1m.md)

Written by Pi Australia from Raspberry Pi's MicroPython documentation, Raspberry Pi's Pico-series documentation, Raspberry Pi Pico-series Python SDK (RP-008355-DS), MicroPython downloads, MicroPython quick reference for the RP2, Thonny, Thonny's MicroPython notes.
