This article will guide you to easily upload Arduino code to Raspberry Pi Pico using the Arduino IDE(Integrated Development Environment). The Arduino platform is popular among hobbyists and professionals alike. Raspberry Pi Pico which has the RP2040 controller is usually programmed using MicroPython or C++. Thanks to the work of contributors in Github, we now have a port of the RP2040 microcontroller to Arduino.
- Arduino IDE 1.8.x or higher.
- A Raspberry Pi Pico or Raspberry Pi Pico W.
- USB cable(Micro B).
Installation Of Raspberry Pi Pico Board on Arduino IDE.
To program Raspberry Pi Pico using Arduino IDE, we need to install some additional components to our Arduino IDE so that the board is recognized by the IDE.
- In the Arduino IDE, go to Tools> Board> Boards Manager.
- Type “Raspberry Pi Pico” in the search field of the ‘Boards Manager’ window. Select the option ‘Raspberry Pi Pico/RP2040’ by Earle F. Philhower. Click on the Install button next to it. More details on this Arduino port can be found in the Arduino-Pico Github repository.
It may take some time for the library installation to complete. You can track the download progress which is shown in the lower part of the Boards Manager dialog box. I did encounter some errors while installing, but clicking Install again a couple of times did the job.
- Close the Boards Manager dialog box when installation is finished.
- Now go to Tools> Board>Raspberry Pi 2040 Boards and select the board that you are using. I selected Raspberry Pi Pico as my board.
How To Upload Arduino Code To Raspberry Pi Pico
- Connect Raspberry Pi Pico to your PC by holding down the BOOTSEL button on the Pico board. Note that this method needs to be performed only once.
- In Arduino IDE, open the code to blink an LED by navigating to File>Examples>Basics>Blink.
- Click the upload icon on the Arduino IDE. The following message was displayed in the terminal when the code was successfully uploaded.
The LED onboard your Raspberry Pi Pico/Pico-W board must now be blinking.
Next time when we reconnect the USB cable and Pi Pico to our computer, we do not need to press and hold the BOOTSEL button while connecting. Simply connect the Pi Pico to your computer, go to Tools>Port in Arduino IDE and select the Raspberry Pi Pico port that is displayed. You can upload Arduino code after the appropriate port is selected.
If the port is not displayed or if any error occurs, repeat the process of holding down the BOOTSEL button while connecting the USB cable.
How To Switch Raspberry Pi Pico Between MicroPython & Arduino IDE
If you wish to program your Raspberry Pi Pico using MicroPython, you need to flash/re-flash a MicroPython UF2 file to it. Read our guide on how to install the MicroPython UF2 file on Raspberry Pi Pico.
When moving from the MicroPython environment to Arduino, we need to repeat the step of holding down the BOOTSEL button while uploading our first program from the Arduino IDE. Likewise, we need to reflash the MicroPython UF2 file when we move from Arduino to the MicroPython programming environment.
If you are unable to flash new firmware on RPi Pico, you can reset your Pico by following our guide: How To Reset Raspberry Pi Pico & Pico W – 3 Easy Ways.