Raspberry Pi Pico 2 Arduino Guide
Raspberry Pi Pico 2 Arduino Guide
Arduino
Created by Anne Barela
[Link]
Overview 3
• Parts
The Raspberry Pi Pico and Pico 2 have revolutionized microcontroller design since
their introduction. Inexpensive and powerful, they are a natural use for a variety of
projects. They can be programmed in different languages to suit the designer.
If you're looking to program your Pico in CircuitPython. check out this guide by
Adafruit:
[Link]
with-raspberry-pi-pico-circuitpython/
overview
If you wish to use Arduino, that can be done also. But it is suggested you follow this
guide. Why?
Back in 2021, when the first Raspberry Pi Pico boards arrived, Arduino provided
support ([Link] through a version of their software coupled with
mbed ([Link] a real-time operating system. While most other Arduino
boards run the Arduino compiled code "bare metal" (without need of an operating
system), the Arduino development environment (IDE) used mbed, adding a layer of
complexity to programming.
Parts
Raspberry Pi Pico RP2040
The Raspberry Pi foundation changed
single-board computing when they
released the Raspberry Pi computer, now
they're ready to...
[Link]
Raspberry Pi Pico W
The Raspberry Pi foundation changed
single-board computing when they
released the Raspberry Pi computer, now
they're ready to...
[Link]
Note the Pico and Pico 2 have a USB micro B connector, not USB-C like many other
boards. If you need to, be sure to get a good USB data+power cable (not the tiny
ones that come with power banks, they're power only).
The Philhower core for Arduino originally focused on RP2040-based boards. When
the RP2350 arrived with the Raspberry Pi Pico 2 (and 2 W), the Arduino board support
package was augmented with support for that chip also.
The following pages describe how to set things up for a Raspberry Pi Pico with
RP2040. The process also applies, with appropriate changes, for other boards based
on the RP2040 microcontroller.
[Link]
global/package_rp2040_index.json
Add the URL to the the Additional Boards Manager URLs field (highlighted in red
below).
Installing a new board package can take a few minutes. Don't click Cancel!
If you are programming a Raspberry Pi Pico or Pico W, ensure you select the
board you have and not a another board as the W boards have LED pinning
different (though it should be transparent to the user if it is coded as shown).
Re. If you have a Pico board, do not select Pico W, Pico 2, or Pico 2 W. If you have a
Pico W, select Raspberry Pi Pico W and don't select Pico or the Pico 2 boards.
Now you're ready to begin using Arduino with your RP2040 board!
When all else fails, you can always come back to Blink!
• Install the very latest Arduino IDE for Desktop (not all boards are supported by
the Web IDE so we don't recommend it).
• Install any board support packages (BSP) required for your hardware. Some
boards are built in defaults on the IDE, but lots are not! You may need to install
plug-in support which is called the BSP.
The Pico has the GPIO pin names listed on the bottom of the board as GPx, where x is
the pin number. The Arduino pin name is the number following GP. So, for example,
pin GP0 would be Arduino pin 0 .
There is an onboard green LED for user use. Unlike many boards, the Pico lacks a
power on LED.
In the IDE find the Tools menu. You will use this to select the board. If you switch
boards, you must switch the selection! So always double-check before you upload
code in a new session.
void setup() {
// Some boards work best if we also make a serial connection
[Link](115200);
void loop() {
// Say hi!
[Link]("Hello!");
Note that in this example, we are not only blinking the LED but also printing to
the Serial monitor, think of it as a little bonus to test the serial connection.
One note you'll see is that we reference the LED with the constant LED_BUILTIN
rather than a number. That's because, historically, the built in LED was on pin 13 for
Arduinos. But in the decades since, boards don't always have a pin 13, or maybe it
could not be used for an LED. So the LED could have moved to another pin. It's best
to use LED_BUILTIN so you don't get the pin number confused!
Note that Verifying a sketch is the same as Compiling a sketch - so we will use the
words interchangeably
During verification/compilation, the computer will do a bunch of work to collect all the
libraries and code and the results will appear in the bottom window of the IDE.
For example, here I had the wrong board selected - and the selected board does not
have a built in LED!
Here's another common error, in my haste I forgot to add a ; at the end of a line. The
compiler warns me that it's looking for one - note that the error is actually a few lines
up!
On success you will see something like this white text output and the message Done
compiling. in the message area.
Upload Sketch
Once the code is verified/compiling cleanly you can upload it to your board. Click the
Upload button.
The IDE will try to compile the sketch again for good measure, then it will try to
connect to the board and upload a the file.
This is actually one of the hardest parts for beginners because it's where a lot of
things can go wrong.
However, lets start with what it looks like on success! Here's what your board upload
process looks like when it goes right:
First up, check again that you have the correct board selected! Many electronics
boards have very similar names or look, and often times folks grab a board different
from what they thought.
If you're positive the right board is selected, we recommend the next step is to put
the board into manual bootloading mode.
Modern chips often have 'native' USB - that means that there is no separate chip for
USB interface. It's all in one! Great for cost savings, simplicity of design, reduced size
A lot of beginners have a little freakout the first time this happens, they think
the board is ruined or 'bricked' - it's almost certainly not, it is just crashed and/
or confused. You may need to perform a little trick to get the board back into a
good state, at which point you won't need to manually bootload again.
If you never get the RPI-RP2 drive, ensure your USB cable is plugged into the
computer and not a USB hub and that the cable is a known good data+power USB
cable.
Once you are in manual bootload mode, go to the Tools menu, and make sure you
have selected the bootloader serial port. It is almost certain that the serial port has
changed now that the bootloader is enabled
After uploading this way, be sure to click the reset button - it sort of makes sure that
the board got a good reset and will come back to life nicely.
After uploading with Manual Bootloader - don't forget to re-select the old Port
again
It's also a good idea to try to re-upload the sketch again now that you've performed a
manual bootload to get the chip into a good state. It should perform an auto-reset the
second time, so you don't have to manually bootload again.
Finally, a Blink!
OK it was a journey but now we're here and you can enjoy your blinking LED. Next up,
try to change the delay between blinks and re-upload. It's a good way to make sure
your upload process is smooth and practiced.
The upgraded Raspberry Pi Pico 2 uses an RP2350 dual Cortex M33 microcontroller.
It increases the computing power by a factor of 2 over the previous RP2040 based
boards.
The Philhower core was augmented to provide support for the RP2350 on the
Raspberry Pi Pico 2 (and 2 W).
The following pages describe how to set things up for a Raspberry Pi Pico 2 with
RP2350. The process also applies, with appropriate changes, for other boards based
on the RP2350 microcontroller.
In the Additional Boards Manager URLs field, you'll want to add a new URL. The list of
URLs is comma separated, and you will only have to add each URL once. The URLs
point to index files that the Board Manager uses to build the list of available &
installed boards.
[Link]
global/package_rp2040_index.json
Add the URL to the the Additional Boards Manager URLs field (highlighted in red
below). If you already have a board support package in that field, type a comma at the
end then add the address above. Both will then be loaded by the Arduino IDE.
In the Boards Manager, search for RP2040. Scroll down to the Raspberry Pi Pico/
RP2040/RP2350 by Earle F Philhower, III entry. Click Install to install it.
Navigate to the Raspberry Pi RP2040/RP2350 Boards menu. You will see the
available boards listed.
Re. If you have a Pico 2 board, do not select Pico, Pico W, or Pico 2 W. If you have a
Pico 2 W, select Raspberry Pi Pico 2W and don't select Pico 2 or the Pico boards.
Now you're ready to begin using Arduino with your RP2350 board!
When all else fails, you can always come back to Blink!
• Install the very latest Arduino IDE for Desktop (not all boards are supported by
the Web IDE so we don't recommend it).
• Install any board support packages (BSP) required for your hardware. Some
boards are built in defaults on the IDE, but lots are not! You may need to install
plug-in support which is called the BSP.
• Get a Data/Sync USB cable for connecting your hardware. A significant amount
of problems folks have stem from not having a USB cable with data pins. Yes,
these cursed cables roam the land, making your life hard. If you find a USB
cable that doesn't work for data/sync, throw it away immediately! There is no
need to keep it around, cables are very inexpensive these days.
• Install any drivers required - If you have a board with a FTDI or CP210x chip,
you may need to get separate drivers. If your board has native USB, it probably
doesn't need anything. After installing, reboot to make sure the driver sinks in.
• Connect the board to your computer. If your board has a power LED, make sure
its lit. Is there a power switch? Make sure its turned On!
The Pico has the GPIO pin names listed on the bottom of the board as GPx, where x is
the pin number. The Arduino pin name is the number following GP. So, for example,
pin GP0 would be Arduino pin 0 .
There is an onboard green LED for user use. Unlike many boards, the Pico lacks a
power on LED.
In the IDE find the Tools menu. You will use this to select the board. If you switch
boards, you must switch the selection! So always double-check before you upload
code in a new session.
void setup() {
// Some boards work best if we also make a serial connection
[Link](115200);
void loop() {
// Say hi!
[Link]("Hello!");
One note you'll see is that we reference the LED with the constant LED_BUILTIN
rather than a number. That's because, historically, the built in LED was on pin 13 for
Arduinos. But in the decades since, boards don't always have a pin 13, or maybe it
could not be used for an LED. So the LED could have moved to another pin. It's best
to use LED_BUILTIN so you don't get the pin number confused!
Note that Verifying a sketch is the same as Compiling a sketch - so we will use the
words interchangeably
During verification/compilation, the computer will do a bunch of work to collect all the
libraries and code and the results will appear in the bottom window of the IDE.
If something went wrong with compilation, you will get red warning/error text in the
bottom window letting you know what the error was. It will also highlight the line with
an error.
Here's another common error, in my haste I forgot to add a ; at the end of a line. The
compiler warns me that it's looking for one - note that the error is actually a few lines
up!
On success you will see something like this white text output and the message Done
compiling. in the message area.
The IDE will try to compile the sketch again for good measure, then it will try to
connect to the board and upload a the file.
This is actually one of the hardest parts for beginners because it's where a lot of
things can go wrong.
However, lets start with what it looks like on success! Here's what your board upload
process looks like when it goes right:
Often times you will get a warning like this, which is kind of vague:
If you're positive the right board is selected, we recommend the next step is to put
the board into manual bootloading mode.
Modern chips often have 'native' USB - that means that there is no separate chip for
USB interface. It's all in one! Great for cost savings, simplicity of design, reduced size
and more control. However, it means the chip must be self-aware enough to be able
to put itself into bootload/upload mode on its own. That's fine 99% of the time but is
very likely you will at some point get the board into an odd state that makes it too
confused to bootload.
A lot of beginners have a little freakout the first time this happens, they think
the board is ruined or 'bricked' - it's almost certainly not, it is just crashed and/
or confused. You may need to perform a little trick to get the board back into a
good state, at which point you won't need to manually bootload again.
Unplug your Raspberry Pi Pico from USB. Ensure the other end of your USB cable is
connected to your computer running the Arduino IDE. Press the BOOTSEL button and
continue holding and plug the USB cable back in to the Pico. Let go of the BOOTSEL
button. A new drive named RPI-RP2 should appear. This is your sign that you can
now load the blink sketch by pressing the right arrow button.
If you never get the RPI-RP2 drive, ensure your USB cable is plugged into the
computer and not a USB hub and that the cable is a known good data+power USB
cable.
Once you are in manual bootload mode, go to the Tools menu, and make sure you
have selected the bootloader serial port. It is almost certain that the serial port has
changed now that the bootloader is enabled
Did you remember to select the new Port in the Tools menu since the
bootloader port has changed?
After uploading this way, be sure to click the reset button - it sort of makes sure that
the board got a good reset and will come back to life nicely.
After uploading with Manual Bootloader - don't forget to re-select the old Port
again
Finally, a Blink!
OK it was a journey but now we're here and you can enjoy your blinking LED. Next up,
try to change the delay between blinks and re-upload. It's a good way to make sure
your upload process is smooth and practiced.