Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (2024)

Learn how to program the Raspberry Pi Pico using Arduino IDE software. The Raspberry Pi Pico is a low-cost microcontroller board developed around the RP2040 chip by the Raspberry Pi Foundation and it can be programmed using MicroPython or C/C++ like the Arduino. In this tutorial, you’ll learn how to set up Arduino IDE to start programming your Raspberry Pico and Pico W boards with C/C++ programming language.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (1)

New to the Raspberry Pi Pico? Read our Raspberry Pi Pico Getting Started Guide.

Don’t have a Raspberry Pi Pico yet? Check it out here.

Table of Contents

  • Installing Arduino IDE
  • Adding the Raspberry Pi Pico to the Boards Manager
  • Programming the Raspberry Pi Pico Using Arduino IDE

You may also like: Learn Raspberry Pi Pico with MicroPython eBook

Installing Arduino IDE

Before proceeding you need to install Arduino IDE on your computer. Currently, there are two versions of Arduino IDE you can install: version 1 or version 2.

You can download and install Arduino IDE by clicking on the following link:

If you want to install version 1, scroll down the page until you find the legacy 1.8.X version.

Adding the Raspberry Pi Pico to the Boards Manager

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

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (2)

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:

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (3)

Note:if you already have the ESP32 and/or ESP8266 boards URL,s 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 boards.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (4)

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.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (5)

Programming the Raspberry Pi Pico Using Arduino IDE

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 or Pico 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.

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 boardvoid setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT);}// the loop function runs over and over again forevervoid 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 in BOOTLOADER mode

For you to be able to upload code to the Raspberry Pi Pico, it needs to 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.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (7)

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…

For the board, select Raspberry Pi Pico or Raspberry Pi Pico 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 UF2 Board UF2 Devices option.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (9)

Now, you can upload the code.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (10)

You should get a success message.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (11)

Demonstration

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

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (12)
Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (13)

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

You may also like: Learn Raspberry Pi Pico with MicroPython eBook

Wrapping Up

In this tutorial, you learned how to set up the Arduino IDE to program the Raspberry Pi Pico using C/C++ programming language, similar to what you use to program the Arduino, ESP32, and ESP8266.

The Raspberry Pi Pico can also be programmed using MicroPython firmware. If you’re interested in programming the Pico using MicroPython, check this tutorial.

You can check all our Raspberry Pi Pico projects and tutorials on the following link:

  • Check out all our Raspberry Pi Pico Guides »

You may also like:

  • Getting Started with the Raspberry Pi
  • SMART HOME with Raspberry Pi, ESP32, and ESP8266

Thanks for reading.

Programming Raspberry Pi Pico with Arduino IDE | Random Nerd Tutorials (2024)
Top Articles
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 5701

Rating: 4.8 / 5 (78 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.