Newbie C++ question

How do you use C++ on the Servo2040 board? Do we copy a C++ uf2 file to the board? Also, what application doe we use to compile programs?

Sorry for the newbie questions, but I can’t find a tutorial on how to do it.

I have zero C skills, just so you know, but I did find this, might help.
Developing in C on the RP2040: First | Wellys Dev

That article also has a link to the ‘official’ Foundation getting started guide which walks you through getting the toolchain sorted out - although it (understandably, perhaps!) assumes you’re on a Raspberry Pi (or other Linux machine); it’s still perfectly doable under Windows, though!

Pimoroni have an excellent boilerplate project to quickly get up and running, which makes it a breeze to link into their libraries for stuff like the Servo2040. The readme on that boilerplate also has a (brief!) list of what you need installing.

1 Like

Answer to the second question: yes. The toolchain creates an utf2-file and you upload it to the board.

Third question: you can use the following applications: PlatformIO, Arduino-IDE, Visual-Studio-Code with various plugins for C++ and Pico development. All of these need the Pico-SDK but will either guide you in setting this up or automate the task.

Where do you find the Servo2040 uf2 file for C/C++?

I think there is an misunderstanding: you writ C++ code, then compile and link it and then you have the utf2. So the utf2 is specific to your special program.

So, I connected the servo2040 and opened the arduino IDE. It wouldn’t recognize the board, so I went to the board manager and installed the “arduino mbed OS rp2040 boards”, then I was able to select the board.

I created a very basic schetch…

#include <Servo.h>

Servo Servo1;

void setup() {

void loop() {

I was able to verify the code successfully. When I tried to upload to the board, I got this error.

Failed uploading: uploading error: exit status 1

Is there a step by step tutorial on how to get this going for C++? I saw this header in the example C++ code

#include “servo2040.hpp”

and not sure how to get these pimoroni specific code to compile.
This board is very frustrating. There’s no tutorial on how to get it going.

There’s a bundle of questions there, but…

While I understand there is some rp2040 support in the Arduino IDE these days, the official guide (linked above) and all of the C++ examples (linked from the product page) kind of assume that you’re using CMake and the rest of the toolchain as described in the guide.

If you want to use the Arduino IDE, you’ll probably have to do some work to make it understand the Pimoroni libraries, but I’ve never used it so you’d have to do some investigations.

Honestly, I would read the official guide at least up to the point of “blink an LED” (chapter 3) because that will walk you through the entire process of getting your code compiled and producing a uf2 file to copy over. Otherwise you’re trying to fix 7 different things at once and tying yourself in knots.

If you’re running under Windows (you don’t say, but I’m guessing so?), then there is a Pimoroni tutorial on precisely that (which also emphasises that if you’re unfamiliar with C, which I’m guessing you are, that MicroPython might be a more approachable environment to start out with)

1 Like

ahnlak, thanks for that C++ tutorial. Although, I’m somewhat competent in linux, I would prefer to use Windows. I’m kinda new to python but have known C/C++ for over 2 decades. The reason I want to try C/C++ on this board is that I tried the “” example and plugged in a LDX-218 servo. For the s.to_min() and s.to_max() statements, before the servo gets to -90 or 90. it pauses for a split sec then goes to the extreme. It’s almost looks like 2 set value statements with a 1/2 sec pause in the middle.

I tried something like s.value(5), then s.value(60). Before it gets to 60 (say around 45) it pauses for a quick sec, then goes to 60. I tried Futaba S3003, MG995, Tower Pro MG90S, and an EMAX ES08MA servos and none of them do this.

I have a Spider DAGU arduino Mega board and tried the LDX-218 servos and it doesn’t pause the servo at all.

I wanted to try C++ on this board to see if it does that pause for the LDX-218 servos. I have a CR-6 hexapod with these servos so changing them would be expensive, and I haven’t seen then pause with any other board.

Is there some config I could set to stop this pausing? I want to write IK for this hexapod, but if I can’t fix the pausing, I’ll reluctantly use the arduino mega spider board instead of the Servo2040.

Is this maybe an Analog versus Digital (servo) thing?
Servo Motor Fundamentals (

I think I figured it out. I may have been underpowering these servos. They are rated at 7.4V. I cut the trace on the back on the servo2040 and powered it with a 7.4v lipo. You can’t see the pause now.

One more question… Does the servo2040 board have interrupt capable pins? if so, which ones?