The Raspberry Pi Pico and Pico W (based on the RP2040 microcontroller) are versatile and affordable development boards that support multiple programming languages, including MicroPython, CircuitPython, and C/C++.
This tutorial will guide you through setting up the Raspberry Pi Pico/Pico W in the Arduino IDE using a third-party library, enabling you to write Arduino-style code for these boards.
We'll further use this library to run a simple example that blinks the onboard LED.
This setup is also compatible with the Raspberry Pi Pico 2 and Pico 2 W (RP2350) as well.
StepsStep 1: Setting Up the Arduino IDE:
Make sure you have the latest version of the Arduino IDE installed. You can download it from the official Arduino website.
Open the Arduino IDE and navigate to File > Preferences .
In the "Additional Boards Manager URLs" field, enter the following URL:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
Step 2: Installing the Raspberry Pi Pico Board Support:
Go to Tools > Board > Boards Manager , search for "Raspberry Pi Pico" in the Boards Manager window, and install the "Raspberry Pi Pico/RP2040/RP2350" package by Earle Philhower .
This package supports various boards like Raspberry Pi Pico, Pico W, Pico 2 and Pico 2 W, making it easy to program them in the Arduino IDE.
Step 3: Connecting the Pico/Pico W to Your Computer
The Raspberry Pi Pico/Pico W supports two upload methods: Serial and UF2 .
The serial method is generally easier and more convenient, as it doesn't require using the "BOOTSEL" button each time.
Connecting via Serial (Easier)
Simply connect your Pico/Pico W to your computer with a USB cable. In the Arduino IDE, go to Tools > Port and select the correct COM port.
Connecting via UF2
If needed, you can enter USB mass storage mode by pressing and holding the "BOOTSEL" button while plugging in the USB cable. This activates the UF2 upload option in the Arduino IDE. The board will appear as a "UF2 Board" under Tools > Port > UF2conv . Select this option to connect to the Pico/Pico W in UF2 mode.
Step 4: Uploading Code to the Pico/Pico W
To upload your code, you can use either method:
Serial Method: Ensure the correct COM port is selected and click Upload in the Arduino IDE. The code will upload directly without needing to enter USB mass storage mode, making this a faster option.
UF2 Method: If using UF2 mode, select "UF2 Board" as the port and upload. After uploading, the board will automatically disconnect and reconnect on a COM port, allowing Serial Monitor communication at the specified baud rate.
With either method, the Pico/Pico W will function like a regular Arduino and allow serial communication after the code uploads.
Example Project: Blinking the Onboard LED
Now that the board is set up, let’s create a simple blink program for the onboard LED.
Open File > Examples > 01.Basics > Blink , which will open a new sketch for blinking the LED.
Upload the code to the board by clicking the "Upload" button. The onboard LED should start blinking.
Benefits of Using Arduino IDE Over MicroPython/CircuitPython:
Familiarity for Arduino Users: If you have experience with Arduino, using the Arduino IDE will feel familiar, as you can use standard libraries and functions.
Wider Ecosystem of Libraries: Arduino has a broad selection of libraries that can be easily integrated into projects, allowing more flexibility and expansion compared to the Python ecosystems.
Speed and Performance: C/C++ (used in Arduino) tends to have better execution speed than interpreted languages like MicroPython.
Conclusion:
You have successfully set up your Raspberry Pi Pico/Pico W with the Arduino IDE and completed the simple blink program.
The Arduino IDE offers a user-friendly environment for those familiar with Arduino, providing a variety of libraries and a vast community.
If you want to explore more, check out my profile for related projects, and don’t forget to follow me for updates on new tutorials and advanced projects!
Comments
Please log in or sign up to comment.