Programming Raspberry Pi Pico with MicroPython | A Beginner’s Guide


In this tutorial, we will learn how to Program Raspberry Pi Pico with MicroPython. We will learn what is MicroPython, how to install MicroPython on Raspberry Pi Pico and how to program Raspberry Pi Pico with MicroPython.
I made a Getting Started with Raspberry Pi Pico tutorial , in which I discussed the RP2040 Microcontroller, the Raspberry Pi Pico Development Board, Pinout of Raspberry Pi Pico. So, check out that tutorial before proceeding.

Introduction
If you are familiar with Computer Programming, then you probably would have heard of Python. Named after Monty Python (and not the snake), the Python Programming Language has become a popular choice among software developers since its initial launch in 1991.
Python was intended for developing applications for desktops, laptops and servers, that have a powerful processor and run an OS. But what if you want to write applications in Python for a small Microcontroller based embedded systems?
Microcontroller boards like Arduino and Raspberry Pi Pico have severe restrictions in terms of memory and processing power and cannot run Python the way big desktops and laptops do.
Here comes MicroPython to the rescue.
What is MicroPython?
MicroPython is a Python Language Interpreter that is developed for Microcontrollers and embedded systems. It was developed by Damien P. George and is written in C. MicroPython is a Python 3 compatible compiler and run time which can run on small microcontrollers.
Even though it is a subset of Python 3, it doesn’t include all the standard libraries of Python as it was developed for constrained systems. Only a few selected Python libraries are included while the remining are written for MicroPython itself (mostly for low-level hardware access).
If you are a software developer who has never worked on hardware, but you want to write applications for microcontroller based embedded systems (either personal or professional projects), then MicroPython is the answer.
Syntactically, MicroPython is very similar to Python. So, if you worked with Python, then working with MicroPython will be very easy (additionally, you get to control the hardware).
If you haven’t worked with Python (like myself), then do not worry. It is an easy language to learn.
What Computer to use?
The official Raspberry Pi Pico documentation is based on using a Raspberry Pi SBC as the host computer (either for MicroPython or C). If you are working with MicroPython, then you can use any computer (Windows, Mac or Linux) as you simply need to download an IDE called Thonny.
But if you are working with C, then I recommend you to use a Linux based system like a Raspberry Pi Computer (if you have one), as it is easy to download the SDK and write C Programs in Linux.
Also, if you are interested in debugging the code, then a Raspberry Pi will be useful as we can use some of the GPIO of...

Top