How to Use the Arduino IDE to Program a Raspberry Pi Pico

Run Arduino Code On Your Raspberry Pi Pico

With your Pico, you can use Arduino's common language and development environment.

How to Use the Arduino IDE to Program a Raspberry Pi Pico

There are two types of wiring coding for your Raspberry Pi Pico. For novice users, the simplest option is to use a Python version such as MicroPython or CircuitPython. For more experienced users, a more technical method is to write code in C/C++.

There is now a third way to write code for our Raspberry Pi Pico: the Arduino IDE, which uses “Arduino Language,” a C++ derivative. Since Arduino has been around for so long, there are a plethora of pre-existing “sketches” (the Arduino word for programmes) and tutorials available for it. If you've previously dealt with Arduino boards, you're probably very familiar with this versatile IDE and vocabulary.

Buy Raspberry Pi Pico Kits, HAT & Expansions

We went through a number of different configuration procedures and discovered two community-created projects that reduce the installation process to only a few steps. The first is pico-setup-windows, a Windows port of Pico's official setup document. The second is Arduino-Pico, which adds Raspberry Pi Pico support to the Arduino IDE. This guide will teach you how to configure your Windows or Ubuntu system to run Arduino code on your Raspberry Pi Pico.

How to Use the Arduino IDE for Windows to Program a Raspberry Pi Pico

1. Download and update the pico-setup-windows installer. This is a big file to copy.

2. Start the installer.

3. Ensure that all of the elements have been chosen. This will download and upload approximately 360MB of files and software on your computer. Contains the files used to create C/C++ files, as well as Visual Studio Code and Git version control.

4. To instal all of the software, click Install. This can take some time, and it can appear lost at times, so be careful.

5. Download and update the Arduino IDE on your computer. We used version 1.8.13, but the beta of version 2.0 still fits.

6. Launch the Arduino software and go to File >> Preferences.

6. Open the Arduino application and navigate to File >> Preferences.
Image credit: Tom's Hardware

7. Add this line to the additional boards manager and press OK.

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

8. Navigate to Tools >> Boards Manager.

Go to Tools >>  Board >> Boards Manager.
Image credit: Tom's Hardware

9. In the search window, type "pico," and then instal the Raspberry Pi Pico / RP2040 board. This will initiate another massive update, this time about 300MB in size.

install the Raspberry Pi Pico
Image credit: Tom's Hardware

10. Pick Raspberry Pi Pico from the Tools >> Board >> Raspberry Pi RP2040 Boards menu.

11. Plug in your Raspberry Pi Pico and use Device Manager to find the COM port to which it is attached.

12. Set the COM port for the Raspberry Pi Pico under Tools >> Port.

set the COM port for the Raspberry Pi Pico
Image credit: Tom's Hardware

13. Navigate to Files >> Examples >> Basics >> Blink to see how we can programme the Arduino.

Blink to test that we can write code to the Arduino.
Image credit: Tom's Hardware

14. Press the Upload button to upload the code to the Raspberry Pi Pico. The default Blink sketch on the Raspberry Pi Pico will light the green LED next to the micro USB connector.

write the code to the Raspberry Pi Pico
Image credit: Tom's Hardware

When the upload is over, the output window will notify us. When you look at your Raspberry Pi Pico, you will see the green LED blinking once every second.

How to Use the Arduino IDE for Linux to Program a Raspberry Pi Pico

For this guide, we used Ubuntu, but the same instructions should function for other Debian-based distributions like Raspberry Pi OS.

1. Launch a terminal and use wget to import the Pico setup script.

$ wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
2. In the same terminal, make the downloaded file executable.
$ chmod +x pico_setup.sh
3. Execute pico setup.sh to begin the installation procedure. If asked, enter your sudo password.

$ ./pico_setup.sh

4. Download and update the Arduino IDE on your computer. We used version 1.8.13, but the beta of version 2.0 still fits.

5. Launch a terminal and connect the user to the "dialout" party. This party has the ability to interact with devices such as the Arduino. Using “$USER” can use the username by default.

$ sudo usermod -a -G dialout “$USER”
6. To make the modifications in effect, log out or restart your machine.

7. Launch the Arduino software and navigate to File >> Preferences.

8. Connect this line to the additional boards manager and press OK.

How to Program Raspberry Pi Pico in Arduino IDE for Linux
Image credit: Tom's Hardware

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

9. Navigate to Tools >> Boards Manager.

10. In the search window, type "pico," and then instal the Raspberry Pi Pico / RP2040 board. This will initiate another massive update, this time about 300MB in size.

11. Pick Raspberry Pi Pico from the Tools >> Board >> Raspberry Pi RP2040 Boards menu.

Raspberry Pi RP2040 Boards and select Raspberry Pi Pico.
Image credit: Tom's Hardware

12. Plug in your Raspberry Pi Pico

13. Execute a command to find the USB device that describes itself as a Raspberry Pi Pico. It was ttyACM0 in our case.

$ dmesg
Run a command to locate the USB device which identifies as a Raspberry Pi Pico
Image credit: Tom's Hardware

14. Navigate to Files >> Examples >> Basics >> Blink to see how we can programme the Arduino.

Blink to test that we can write code to the Arduino
Image credit: Tom's Hardware

15. Press the Upload button to send the code to the Raspberry Pi Pico. The default Blink sketch on the Raspberry Pi Pico will light the green LED next to the micro USB connector.

write the code to the Raspberry Pi Pico
Image credit: Tom's Hardware

When the upload is over, the output window will notify us. When you look at your Raspberry Pi Pico, you will see the green LED blinking once every second.

Credit To Author: LES POUNDER 

Related Articles: