Thonny with MicroPython

Thonny is a Python IDE that makes running code on your Pico easy.

Thonny allows you to write Python code, save it on your Pico and run it. This guide will show you how to use it with MicroPython


Install Thonny

Download Thonny from here and install it on your computer.

Thonny

Turn on the option to view files:

View files

Plug your Pico into your computer’s USB.

At the bottom right select the MicroPython option:

Micropython option

You should see that there are no files currently on your Pico:

Files

Run a Hello World program

Create a new file by right-clicking in the files area:

Create file

Name the file hello.py:

Hellopy

Enter the following code:

Hello

Run the code by pressing the play button:

Play

You should see the result appear:

Result

Note that this code is running on the Pico, not your computer!

Blink the Built-in LED

The Pico has an LED that you can flash with some code.

Create a new file called blink.py and enter the following code:

# Blink the built-in LED

from machine import Pin
from time import sleep

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

for i in range(10):
    led.on()
    sleep(1)
    led.off() 
    sleep(1)

Run this code. The LED should flash 10 times.