Install Pi Pico in Arduino IDE
The support of the Pi Pico board on Arduino IDE was not long in coming. It is now possible to program the Raspberry Pi Pico board with the Arduino code directly from the Arduino IDE. Adding the support is similar to installing ESP32 boards through the additional board manager through the Arduino IDE.
Installing the Arduino IDE software
If you still don’t have the Arduino IDE installed, you can refer to the first part of the tutorial for the ESP32.
The installation of the software itself is straightforward.
Add RP2040 support in the Arduino IDE.
- To install the necessary tools of the Pi Pico, you should :
-
-
- Go to File> Preferences
-
- Click on URL for additional board managers and add the following URL:
-
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
Warning
You should not remove existing URLs if you are also programming on ESP8266 / ESP32 from the Arduino IDE.
-
Then you have to go to the board manager: Tools> Board type> Board manager . Scroll all the way down until you find Raspberry Pi Pico / RP2040 and click on install. The installation of the development tools is done automatically. You just have to wait.
Note
The download may take a little while, depending on your internet connection.
-
You can change the board type when the installation is finished by choosing the Raspberry Pi Pico board.
Upload a program to the Pi Pico:
Uploading a program to the Pi Pico is different than Arduino and ESP32 boards: For the Pi Pico, to receive a new program, it must be in “USB” mode. If you already have MicroPython installed on the Pi Pico, you will need to manually put the board into BOOT mode by pressing down the BOOT/BOOTSEL button while connecting to the computer. You cannot directly download a program with MicroPython running on the Pi Pico.
Warning
Remember to save all the possible Python scripts present in the MicroPython file manager before putting the Raspberry Pi Pico in USB mode. Indeed, all the flash memory will be overwritten by the new Arduino sketch.
Once you’ve manually put the Pi Pico into USB mode, you can verify that the Arduino sketch upload is working. You can take the example of the blink code accessible in Files> Examples> Basics> Blink , which makes the built-in LED of the board blink.
You can also directly copy the code below:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(750); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(750); // wait for a second
}
Then just click on the standard arrow to compile and upload the program. The first compilation takes a little time, but the following will be faster.
In future uploads, the Pi Pico will go directly into USB mode, so it will no longer be necessary to press the BOOTSEL button.
- In fact, with every upload, the following things happen:
-
-
The serial link via a COM port is stopped.
-
The Pi Pico board goes into USB mode: it acts as a USB key.
-
The Pi Pico board receives its new program compiled with the UF2 extension: it is copied into its memory.
-
The Pi Pico restarts by executing the new program and activates its serial link again.
-
Note
The only annoying thing is that you can hear the characteristic Windows detection beep on each upload.
Well done, you can now use the Arduino code to program the Pi Pico. Therefore, you can take your programs made for an Arduino and possibly adjust it a little for the Pico.
Note
Some libraries may not be yet compatible with the Pico since the port of the Pi Pico with the code is recent.