Recently I was receiving my Raspberry PI Pico and I had the opportunity to play around with it. Actually most of the time I spent reading the Manuals... The conclusion: interesting - but a little bit too complicated. So I was quite happy to read that Arduino plans to add an official support for this Microcontroller.
However I did not want to wait for the official support to be available, so as a temporary solution, I decided to make my own Arduino API availale as a separate project.
Design goals
- Provide a full implementation of the Arduino API
- Provide additioal easy to use C++ classes for the functionaity which is specific to the Pico
- Keep the pico specific build process using cmake
- Support of existing Arduino Libraries
- Provide examples
Installation
- First you need to install the Pico C Framwork. Please follow the instructions and do not forget to define the PICO_SDK_PATH environment variable.
- Clone this project with
git clone https://github.com/pschatzmann/pico-arduino
- Define the environment PICO_SDK_ARDUINO_PATH variable to point to the project location.
- Build the arduino library (optional). The project already contains the compiled library. However I would recommend to rebuild it from the source.
To build the arduino library go to the pico-arduino/Arduino subdirectory
and execute the steps below:
mkdir build
cd build
cmake ..
make install
You can find the resulting library in the pico-arduino/lib directory.
Examples
Details can be found in the examples directory
Documentation
The generated Class documentation can be found in the doc folder
Pinout
It helps to know the functions of the pins. Here is a copy of the pinout provided by the official Raspberry Pi Pico Documentation:

If a method is requiring a pin you can provide the GPIO number as integer or use the corresponding GP name as given in the sheet above.
The following calls are all identical:
digitalWrite(25, HIGH); // turn the LED on using integer
digitalWrite(GP25, HIGH); // the same with GP25 define
digitalWrite(LED_BUILTIN, HIGH); // the same with Arduino defines
digitalWrite(PICO_DEFAULT_LED_PIN, HIGH); // the same with Pico defines
Deploying a compiled Sketch
Deployment is very easy - just press the button on your Pico while plugging it to your computer via USB. This will automatically mount the Pico as external drive (RPI-RP2). Finally you just need to copy the generated uf2 file from your build directory to the drive.
That's it!
Project Status
- Basic Arduino API (e.g. String, Serial...) - completed
- digital input/output API - completed
- analog input/output API (PWM) - completed
- Multiprocessor support: queue, semaphore - completed
- tone - completed
- Arduino SPI API - completed
- PIO API class - completed
- Arduino I2C API - completed
- Software Serial using PIO - completed
- I2S API using PIO - open
Change History
- v0.1 Initial Version with Baisic Functionality
- v0.2 SPI Support & error corrections
- v0.3 I2C Support & error corrections
- v0.4 Software Serial & error corrections
- v0.5 Error corrections, cleanup and more examples
- HardwareSerial: Corrected Delays in print and println
- analogWrite correction provided by Duke Dylan
- Moved examples documentation into examples folder
- Examples for HC-05 and ESP01
- This release contains the following Breaking Changes
- Changed signature of SoftwareSerial.begin() by switching the tx and rx sequence to be consistent with HardwareSerial
- Removed subfolders in ArduinoCore-Pico folder