Programming Raspberry Pi Pico 2 and 2 W with Arduino IDE 

Learn how to program the Raspberry Pi Pico 2 or 2 W boards using Arduino IDE. The Raspberry Pi Pico 2 / 2 W is a microcontroller developed by the Raspberry Pi Foundation, built around the RP2350 chip. It offers a wide range of GPIO pins for connecting peripherals and can be programmed using MicroPython or C/C++. In this tutorial, you’ll learn how to program it using C/C++ programming language using Arduino IDE software.

Programming the RPi Pico 2 and 2 W with Arduino IDE

What is the Raspberry Pi Pico 2?

The Raspberry Pi Pico 2 is the successor of the Raspberry Pi Pico. It uses the RP2350 chip. It is a microcontroller board like the ESP32 or ESP8266 (not a microcomputer like the Raspberry Pi). Similarly, it can be programmed using Arduino IDE and some of the same methods and functions you would use with the ESP32 and ESP8266 boards.

Where to Buy Raspberry Pi Pico 2?

The Raspberry Pi Pico 2 W board is widely available on many different stores. Check the following link to compare its price on different stores:

Raspberry Pi Pico 2 W

New to the Raspberry Pi Pico 2? Check our getting started guide: Getting Started with Raspberry Pi Pico 2 and Pico 2 W.

Programming the Raspberry Pi Pico 2 Using Arduino IDE

Follow this section to learn how to program the Raspberry Pi Pico boards using Arduino IDE.

Installing Arduino IDE

Before proceeding, you need to install Arduino IDE on your computer. Install version 2 of the Arduino IDE. You can download and install Arduino IDE by clicking on the following link:

Adding the Raspberry Pi Pico to the Boards Manager

1. In the Arduino IDE, go to File > Preferences.

Arduino IDE Preferences

2. Enter the following URL into the “Additional Boards Manager URLs” field:

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

Then, click the “OK” button:

Additional Boards Manager URL Arduino IDE 2

Note: if you already have the ESP32 and/or ESP8266 boards URLs, you can separate the three URLs with a comma as follows:

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json, https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json

3. Open the Boards Manager. Go to Tools > Board > Boards Manager…

4. Search for “pico” and install the Raspberry Pi Pico/RP2040/RP2350 boards by Earle F. Phillhower.

Install Raspberry Pi Pico 2 Boards Arduino IDE 2

5. That’s it. It will install after a few seconds.

6. Now, if you go to Tools > Board, there should be a selection of Raspberry Pi Pico boards.

Raspberry Pi Pico Board Options Arduino IDE 2

Now you have everything prepared to start programming your Raspberry Pi Pico board using Arduino IDE. Don’t connect the board to your computer yet.

1. Selecting your Pico Board

Go to Tools > Board and select the Raspberry Pi Pico model you’re using—Pico 2 or Pico 2 W (wireless support).

2. Loading the Blink LED Sketch

As an example, we’ll upload the classic Blink LED sketch. Go to File > Examples > 1. Basic > Blink.

The following example should load.

Programming the Raspberry Pi Pico Using Arduino IDE Blink LED sketch

Or you can copy the following code:

/*
  Blink -  Turns an LED on for one second, then off for one second, repeatedly.
  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at: https://www.arduino.cc/en/Main/Products
  modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi modified 8 Sep 2016 by Colby Newman  This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
  
  Programming Raspberry Pi Pico with Arduino IDE: https://RandomNerdTutorials.com/programming-raspberry-pi-pico-w-arduino-ide/
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

View raw code

3. Connecting the Raspberry Pi Pico 2 in BOOTLOADER mode

To upload code to the Raspberry Pi Pico, it must be in bootloader mode.

If the Raspberry Pi is currently running MicroPython firmware, you need to manually put it into bootloader mode. For that, connect the Raspberry Pi Pico to your computer while holding the BOOTSEL button at the same time. A new mass storage device window will open on your computer. You can ignore it and close that window.

Put Raspberry Pi Pico 2 into bootloader mode

For future uploads using Arduino IDE, the board should go automatically into bootloader mode without the need to press the BOOTSEL button.

Now, open the top drop-down menu and click on Select other board and port…

arduino IDE 2 select other board and port

For the board, select Raspberry Pi Pico 2 or Raspberry Pi Pico 2 W.

The COM port might not show up on your first upload, so you need to tick the Show all ports option. Then, select the COM port.

Arduino IDE 2 select Raspberry Pi Pico COM port.

Now, you can upload the code.

Arduino IDE 2 Upload Button

You should get a success message.

Upload code to Raspberry Pi Pico 2 using Arduino IDE OK

Demonstration

If everything went as expected, the Raspberry Pi Pico onboard LED should be blinking every second.

And that’s it. You successfully programmed your Raspberry Pi Pico 2 using Arduino IDE.

Wrapping Up

In this guide, you learned how to program the Raspberry Pi Pico board using Arduino IDE. It shares many of the same functions also used for programming ESP32, ESP8266, and Arduino boards.

We have more tutorials on how to program the Raspberry Pi Pico board using Arduino IDE (all tutorials are compatible with version 1 and version 2 of the Pico board).

For more resources, you can check all our Raspberry Pi Pico Projects and Guides here.

Thanks for reading.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.