6Program your Pico with MicroPython

A beginner-friendly option, while still powerful

Perhaps the most commonly used way to program a Pico is in MicroPython. The Thonny IDE includes built-in support for MicroPython, making uploading your code directly to the Raspberry Pi Pico extremely quick and easy. Thonny is arguably the most commonly used environment for programming Pico projects.

The Pimoroni Pico Plus 2 W
Source: Pimoroni

MicroPython is a lightweight version of Python, a beginner-friendly language. It features clean and intuitive syntax and is less complex than the low-level programming often associated with C or C++. It is perfect for beginners and intermediate users alike.

MicroPython was explicitly designed for microcontrollers. As such, it has extensive support built in for hardware interfaces like GPIO pins, I2C, and SPI. This makes it easy to control sensors, motors, and other peripherals connected to the Pico.

5Use CircuitPython for a web-based code editor

Bringing drag-and-drop to microcontroller development

Next up is Adafruit’s fork of MicroPython, CircuitPython. With CircuitPython, there’s no need to download an app to your computer since you can run it straight from your browser. It also provides easy drag-and-drop functionality, letting you copy your code to the microcontroller, just like transferring a file to a USB drive.

Plugging a Raspberry Pi Pico into a breadboard

CircuitPython includes the libraries needed for the most common peripherals, sensors, and other components you might use in your project. The interface also offers modules for easily programming complex components like OLED displays.

4Use the familiar Arduino IDE to program your Raspberry Pi Pico

A tried and true option for veteran microcontroller programmers

Another solid option is the Arduino IDE, especially if you’re already used to programming for Arduino microcontrollers. You can program your Pico in either C or C++ using the Arduino framework.

The Adafruit BME280 library in the Arduino IDE

The Arduino IDE also includes many additional libraries for most sensors, motors, displays, and other components you might use in your project. You’ll also find even more community support than even the Raspberry Pi ecosystem has, including tutorials, examples, and forums.

3Programming a Raspberry Pi Pico in C or C++

Leveraging the sheer power of low-level programming

As seen above, you can use the Arduino IDE to program your Pico in the C or C++ programming languages. You can also program the microcontroller in either of those languages without the Arduino IDE. This will require installing a software development kit and other programming tools, but it’s a convenient option for anybody already experienced in such low-level programming. This also allows direct access to the Pico’s hardware.

The RP2350 chip
Image Credit: Raspberry Pi

If you have the toolchain installed, you can do your coding and compilation all from the command line. This includes the GCC Arm compiler and CMake. CMake is used to configure your build environment and generate the necessary files for the compiler.

Experienced developers often find using C or C++ offers the best balance of control and performance when programming for the Raspberry Pi Pico. The ability to fully optimize your code makes it ideal for projects reliant on high efficiency, such as embedded systems, robotics, and IoT applications where resource constraints are a concern.

2Using an IDE to program your Pico

Incorporating tools that make programming and debugging easier

You can program the Raspberry Pi Pico using a code editor like Sublime Text, Visual Studio Code, or even a simple code editor. However, it is highly recommended that you use an Integrated Development Environment (IDE). These tools provide syntax highlighting and debugging features that make the job much easier.

Buttons and Pico on a breadboard

Most available IDEs will integrate easily with the Pico SDK and CMake, allowing you to start quickly. I’ve already mentioned several compatible IDEs: Thonny and the Arduino IDE. You can also leverage the power and capabilities of the full Visual Studio Code IDE, CLion, or PlatformIO.

1

More advanced ways to write code for your Raspberry Pi Pico

Assembly language as well as newer embedded systems programming languages

There are other methods to write code to run on your Raspberry Pi Pico microcontroller. These will give you more control over the project board but may require more advanced programming skills and knowledge.

 

For example, the Pico can be coded using the Rust programming language. Rust is known for avoiding many common pitfalls of C and C++, such as data races or memory errors. This requires setting up a Rust toolchain for the microcontroller, but it’s a powerful choice for embedded systems programming.

 

Pimoroni Pico Plus 2 WSource: Pimoroni

You can also do bare-metal assembly programming, which offers total control over the hardware. Naturally, this will require more intimate knowledge of the RP2040 or RP2350 microcontroller, so it is generally suitable only for experienced developers.

 

You might also program the microcontroller in a real-time operating system (RTOS) like FreeRTOS. This allows for concurrency handling, real-time multitasking, and task prioritization. However, this adds another layer of complexity to your programming environment and more challenging debugging.