Strange behavior with a continuous servo

I’m puzzled. I have a small continuous servo (MG995). Using the Servo library, I can rotate the servo in two directions by changing the writeMicroseconds value. No problem. However, the servo will run slower and slower and come to a halt after a few minutes. How is this possible?

#include <Servo.h>
Servo servoLeft;

void setup() {
  servoLeft.attach(13);
  servoLeft.writeMicroseconds(1500);
}  
 
void loop() {
}

Hi, I presume that the code you posted is supposed to make the servo continuously rotate in one direction? But you are finding that it slows to a stop after a few minutes.

How are you powering the servo? If you are using the Arduino 5V it will not be able to supply the current necessary to drive the servo, especially continuously, you will need a separate supply for the servo with its gnd connected to the Arduino's gnd.

What model Arduino are you using?

Thanks.. Tom.. :)

I'm using a Leonardo and powering the servo from an external 5V/2A power source.

Hi, Have you got the servo supply gnd connected to the Leonardo gnd?

Tom... :)

Yup (I guess the servo wouldn't move at all if the ground wasn't connected to the Arduino?)

Hi,

Can you try and put

 servoLeft.writeMicroseconds(1500);

in the loop function instead of the setup.

Tom… :slight_smile:

OK will try that this evening. I always thought that was unnecessary.

I have a small continuous servo

Please don't call it a servo - it raises unrealistic expectations.

The ex-servo almost certainly has analogue innards, which may drift over time/temperature.

AWOL: The ex-servo almost certainly has analogue innards, which may drift over time/temperature.

Quite possible, does putting the writeMicroseconds inside the loop resolve this problem?

No.