Servo example code doesn't compile on RP2040

Hi, I am new to Arduino community. And I want to use this nano RP2040 to control a servo motor. So I started with the example code. There was no error during the verifying, but after the uploading the board simply didn't run the sketch. Any solution or explanation on this? I suspect the servo.h library is not compatible with RP2040.

Dead right. But did the compiler let you get away with including the standard servo library?

Also servos run on 5V and the RP2040 only gives out 3V3 signals.

RP2040 does have a 5V output, but this is irrelevant in my case. Because the code itself doesn't run at all, I can tell it from the serial monitor. For the compiler part, it is a little bit confusing. I saw a warning once, but it didn't interrupt the compiling. And after I pressed the reset button, no warning again during the compiling. Do you know any alternatives to control a servo motor?

You can try my RP2040_ISR_Servo library which supports these RP2040 boards

I also have used this library on my RP2040 connect and it works fine. Be sure to supply external 5V power for the servo.

1 Like

That is only the voltage output direct from the USB connector. All the signals are 3V3. They will be just under the limit to guarantee working of a servo. But marginally you might get away with it, however it might not work reliably.

I actually tried your library. It works when I control it offline. The servo motor does whatever I tell it to do. However, when I try to make it an IoT, namely, I use a bool variable to instruct the motor to turn certain angle through the cloud, the motor does not respond for most of the times. There are a few times when I control it successfully. When I try Servo library on the nano 33 board, and basically same IoT sketch, it works all the time. Do you have any ideas what is the reason behind it?

It's good that you are successful to use the library offline, which proves that the library is working OK and fulfilling its task successfully. What happens in IoT is beyond the library's reach.

If the motor is not responding when being controlled online, the bug must be in your IoT code.

Even the code is working on Nano_33_IoT, it can't 100% work on Nano_RP2040_Connect.

Unless you post the code here and hopefully someone will help, only you can debug and know what's wrong with your code, by including certain debugging code to verify the Servo commands correctly reach the board and the board issues the correct commands to the Servo.

Good Luck,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.