Servo motor not working with "write"

Hello all,

I’m a student new to Arduino, and I’m trying to control a servo motor by using write command. However, when I run the code, it just keep rotating clockwise for a small angle at a time, and the time interval does not follow the delay too.

Here is my code:

//Include servo library
#include <Servo.h>
const int servopin = 3;
Servo myservo;

void setup()

void loop()

I’m using Arduino Nano & servo motor GWS03T. Thanks for any help :slight_smile:

(Sorry but English is not my mother tongue, so if there is anything not described clearly, please let me know.)

Here is the video:

Servo write takes only positive numbers. See the Servo write() function reference.

You may need to allow more time for the servo to move. A data sheet that I found has the motion versus time specification. Note that the times are usually unloaded times. A servo with a load will be slower, depending on load.

I’ve tried to use the positive parameters, but the problem was still there…

What do you mean to “allow more time?”, I don’t really understand that part.
Thanks for the reply.

It takes time for the servo to start, move to the commanded position and stop. Look at the data sheet under speed:

Speed: 4.8V: 0.33 sec/60° 6.0V: 0.27 sec/60°

with a 4.8V power supply it takes 330ms to move 60° under no load, so to move 90° it would take 495ms (under no load).

How is your servo powered? If it is powered by the Arduino, that can cause problems, too. The Arduino is not a power supply. Power the servo with an external supply like a pack of 4 AA batteries.

Yes, I powered it only by the Arduino.

So the 5V power supply on the Arduino board is not enough?
Ok, I’ll try to give it external power supply.
Thanks a lot!