MicroMod RP2040 Processor Board Hookup Guide

Pages
Contributors: bboyho
Favorited Favorite 0

MicroPython Examples

The Raspberry Pi foundation has provided the necessary tools, documentation, and examples to get started with the RP2040. If you haven't already, check out the documentation on the Pico. We'll use this as a reference when using the chip on other development boards to fit your needs in this tutorial.

We'll be using the MicroPython examples from this GitHub repo using Thonny IDE.

Installing MicroPython on the RP2040

To install MicroPython on the RP2040, you will need to download the firmware from Raspberry Pi. Click below to head to the Raspberry Pi Foundation's MicroPython UF2 File for the RP2040. Click on the tab for the "Getting started MicroPython" and the button for Download UF2 File.

On your MicroMod carrier board, find the boot and reset button. Press and hold the boot button down with one finger.

Finger on Boot Button

Press the reset button with momentarily with another finger.

Fingers on Boot and Reset Button Finger of the Reset Button

Release the boot button. The board should appear on your computer as a removable drive called RPI-RP2.

Release Boot Button

Draw and drop the UF2 file into the "removable drive". The board will automatically reboot. Below is an image highlighting the UF2 file being moved to a the removeable drive on a Raspberry Pi.

Drag and drop MicroPython UF2 file to the removable drive on a Raspberry Pi

Configuring Thonny IDE

Open Thonny up from the start menu: Raspberry Pi Start Menu > Programming > Thonny Python IDE

Open Thonny IDE from the Pi Start Menu

Set Thonny's interpreter for the RP2040. The "Raspberry Pi Pico" will work for the RP2040. Head to the menu and select: Run > Select Interpreter....

Selecting Interpreter for Thonny

This will open a new window for the Thonny options. In the Interpreter tab, select MicroPython (Raspberry Pi Pico) as the interpreter.

Selecting MicroPython for the RP2040

In the same window, make sure to select the option to have Thonny automatically detect the COM port for the board: Port > < Try to detect port automatically >

Select COM port

Hello World!

To check if this is working open the Thonny IDE, type the following into the editor. Feel free to adjust the message to whatever you prefer.

language:python
print("Hello world!")

Hit the "Run current script" button. In the Shell, you will see the following output. Sweet!

language:bash
>>> %Run -c %EDITOR_CONTENT
Hello world!

Hello world! printed to the Thonny Shell from the RP2040

Blink

If you have the MicroPython examples saved, head to the following folder in your downloads .../pico-micropython-examples/blink/blink.py . Your code should look like the following. Of course, you can also copy and paste the code provided after the next paragraph as well.

language:python
# ========== DESCRIPTION==========
# The following code was originally written by 
# the Raspberry Pi Foundation. You can find this
# example on GitHub.
#
#     https://github.com/raspberrypi/pico-micropython-examples/blob/master/blink/blink.py

from machine import Pin, Timer

led = Pin(25, Pin.OUT)
tim = Timer()
def tick(timer):
    global led
    led.toggle()

tim.init(freq=2.5, mode=Timer.PERIODIC, callback=tick)

Hit the "Run current script" button. Once the code runs, you will see the LED blink. If you want the board to run blink every time the board is powered up, just follow the note provided at the end the previous example.

Raspberry Pi and a MicroMod RP2400 Blinking with MicroPython