This tutorial is a getting-started guide for the Raspberry Pi Pico (And Pico W) boards using Arduino IDE. The RP2040-based Raspberry Pi Pico boards can also be programmed using (C/C++ SDK, MicroPython, CircuitPython, and Rust). You can find navigation buttons on the left sidebar to go to the Raspberry Pi Pico tutorials series using the programming language you prefer.
In this tutorial, we’ll set up all the required software tools and get our Raspberry Pi Pico board ready to flash our first Arduino C++ LED Blinking test code using Arduino IDE. Without further ado, let’s get right into it!
Table of Contents
- Raspberry Pi Pico Arduino IDE Install
- Installing Raspberry Pi Pico in Arduino Boards Manager
- Programming Raspberry Pi Pico Using Arduino IDE
- Raspberry Pi Pico LED Blinking (Arduino IDE)
- Raspberry Pi Pico Arduino Simulation (Wokwi)
- Concluding Remarks
Raspberry Pi Pico Arduino IDE Install
To proceed with this tutorial, you need to have Arduino IDE installed on your computer machine. You can head over to the Arduino website & download the IDE using the link below.
Any Arduino IDE version will work just as fine. Arduino Version 1.8.x is called legacy and it’s the most common IDE version used till today. The new Arduino 2.0.x version has some new features, theme options, debugging, and other capabilities that you may need to check out.
Installing Raspberry Pi Pico in Arduino Boards Manager
Now, we need to install the Raspberry Pi Pico Arduino Core to add the Pi Pico Boards support package to the Arduino IDE’s board manager. And here’s how to do it step-by-step:
Step #1
Open your Arduino IDE, click on File, then choose Preferences, and you’ll have the following window opened. In the “Additional Boards Manager URLs” textbox area, you’ll need to add the following URL. If you’ve other boards support package URLs, you’ll just need to add a comma for separating URLs.
Raspberry Pi Pico Arduino Hardware Support Package URL:
1 |
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json |
Now, the URL pointing to the Raspberry Pi Pico Arduino hardware support package is placed but it’s not yet downloaded or installed. So we need to install it next.
Step #2
In your Arduino IDE, click on Tools, then move to the Boards drop list, and choose the Board Manager option.
Search for “pico”, and you’ll easily find it. Click install and let it download and install the files as shown below.
Step #3
To check that you’ve set up the Arduino Raspberry Pi Pico hardware support, open the Tools menu, and check the Boards tab. It should have an option for Raspberry Pi Pico boards.
Programming Raspberry Pi Pico Using Arduino IDE
Here is a step-by-step guide for how to program the Raspberry Pi Pico using Arduino IDE.
Step #1
Open the Arduino IDE, and copy the following code that blinks the onboard LED of the Raspberry Pi Pico board.
1 2 3 4 5 6 7 8 9 |
void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { // Toggle onBoard LED digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); delay(100); } |
Step #2
Hold the BOOTSEL button of the Raspberry Pi Pico board before connecting it to the USB port of your PC. While holding the BOOTSEL button, connect the Raspberry Pi Pico to your PC’s USB port.
It’ll boot in the bootloader mode and your PC will detect it, so you’re now free to release the BOOTSEL button.
Step #3
In your Arduino IDE, make sure that you’re selecting the correct Raspberry Pi Pico, Pico W, or any other RP2040-variant board. Also, check the selected COM port, and click on the upload button.
Wait till completion, the Raspberry Pi Pico board will restart automatically and start executing the new code that we’ve just flashed.
Raspberry Pi Pico LED Blinking (Arduino IDE)
And now let’s write our first LED Blinking Arduino code and run it on the Raspberry Pi Pico. Here is the code listing for this example demo project:
Raspberry Pi Pico (Pico W Compatible)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/* * LAB Name: Raspberry Pi Pico Arduino IDE (Project Template) * Author: Khaled Magdy * For More Info Visit: www.DeepBlueMbedded.com */ void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { // Toggle onBoard LED digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); delay(100); } |
As you can easily tell, it sets the onboard LED pin as an output pin. And toggle its state every 100ms and keeps repeating forever.
If you’re going to use this code example with a Raspberry Pi Pico W board, you need to select it in the Tools > Board menu option.
This article will give more in-depth information about the Raspberry Pi Pico GPIO pins and their functionalities. And how to choose the suitable pins for whatever functionality you’re trying to achieve and know the fundamental limitations of the device with some workaround tips and tricks.
Raspberry Pi Pico Arduino Simulation (Wokwi)
As of writing this tutorial, there is only one Raspberry Pi Pico simulator that looks very promising: the online Wokwi simulator tool. There is a dedicated tutorial guide for “Raspberry Pi Pico project simulation” linked below in this section hereafter.
This is the simulation result for the previous Raspberry Pi Pico LED Blinking example project (Arduino) using Wokwi. You can find the Project Simulation file link here, so you can save a copy of it into your Wokwi projects dashboard and play around with the simulator environment.
Simulating your Raspberry Pi Pico projects can be really helpful especially when you’re just getting started. This step is not mandatory at all, however, running your project in a simulator environment will help you catch and fix some logic errors in the code or in the circuit wiring connections.
The Wokwi simulation project linked above will be our template for all Raspberry Pi Pico Arduino IDE Tutorials, so you need to take a copy of it into your Wokwi account project dashboard.
This article will provide more in-depth information about simulating Raspberry Pi Pico projects using the online Wokwi simulator tool. You’ll learn how to simulate MicroPython, Arduino, and C SDK projects on Raspberry Pi Pico.
If you’re looking forward to playing around with the Raspberry Pi Pico board to test its capabilities and features, you may just need to get a single board. Just like this one here. However, if you’d like to follow along with the Raspberry Pi Pico series of tutorials published here on our website, you may consider getting the following items:
2x Pi Pico Boards, 2x Pi Pico W Boards, 4x BreadBoards, Resistors, LEDs, Buttons, Potentiometers, etc. The reason behind getting multiple boards is that we’ll be using one board as a PicoProbe debugger for SWD debugging activities. And at least 2x Pico W boards for IoT wireless applications.
The full kit list of the Raspberry Pi Pico series of tutorials is found at the link below, as well as some test equipment for debugging that you may consider getting for your home electronics LAB.
Concluding Remarks
To conclude this tutorial, we can only say that it’s only the first step in the Raspberry Pi Pico Arduino Programming journey. The following tutorials in this series will help you get started with Raspberry Pi Pico programming and learn more topics with practical examples and step-by-step explanations.
Follow this Raspberry Pi Pico Series of Tutorials to learn more about Raspberry Pi Pico Programming in different programming languages’ environments.
If you’re just starting with Raspberry Pi Pico, you should check out the following getting-started guides with the programming language you favor the most. There are 4 variants of the Raspberry Pi Pico tutorials to match your needs and help you along the path that you’re going to choose.