Servo Sweep Overshooting Frustration

Hooked up a GWS S35+ XF servo motor (Pololu - GWS S35 STD Continuous Rotation Servo) as shown in the first photo. I've tried uploading the sweep code taken from here ( but the motor is massively overshooting the 180 degrees and I have no idea why.

I have a video of how it's behaving I'm not sure if I'll be able to upload it- I've tried twice already and kept losing the text I'd written for this post in the process. I will see if I can cut it down.

I feel it must be a relatively simple solution but I'm at a loss and the frustration is getting to me, any advice would be massively appreciated, cheers!

Have you sent the servo to 0 and marked the 0 position, like repositioning the connected arm/horn?

Have you considered the red wire in your picture? The red wire is taking Uno power and supplying it to the servo. In your research you may find that the stall current of a tiny plastic mg90something servo wants .8 amps. For hobby grade servo's I allocate an amp per servo. In your research you may find out how much current the Uno will supply. You may find that the servo will want a lot more current than the Uno can supply. You may come to realize, when that happens the Uno dies.

You should be powering the servo with its own power supply. Connect those ground together.

Now about that code, if you could, post your formatted code in code tags so we can have a looksie?

video clip attached via imgur:

Excuse the spiderman pyjamas

Code attached

<#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position

I’ve tried using code such as this one for moving the servo to set positions but found I just infinite continuous rotation except for the 90 position which stops the servo from moving. I also moved the signal wire to the 7 pin for these tests.


// zoomkat 12-25-13 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// Send an a to attach servo or d to detach servo
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually DOES NOT WORK.

#include <Servo.h>
String readString; //String captured from serial port
Servo myservo; // create servo object to control a servo
int n; //value to write to servo

void setup() {
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7, 500, 2500); //the pin for the servo control, and range if desired
Serial.println(“servo all-in-one test code 12-25-13”); // so I can keep track of what is loaded

void loop() {
while (Serial.available()) {
char c =; //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character

if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string

// attach or detach servo if desired
if (readString == “d”) {
myservo.detach(); //detach servo
Serial.println(“servo detached”);
goto bailout; //jump over writing to servo
if (readString == “a”) {
myservo.attach(7); //reattach servo to pin 7
Serial.println(“servo attached”);
goto bailout;

n = readString.toInt(); //convert readString into a number

// auto select appropriate value
if(n >= 500)
Serial.print("writing Microseconds: ");
Serial.print("writing Angle: ");

bailout: //reenter code loop
Serial.print(“Last servo command position: “);
readString=””; //empty for next input

On powering the motor from the arduino itself, I’d assumed the kind of issues discussed in forums would mean this was only a problem if the motor wouldn’t start moving- how would I know this is an issue in my example?

I can see the uno can draw a max of 40 mA, but can’t seem to find what the stall current for my motor is? Is the .8 amps a general rule of thumb?

Thanks for getting back to me!

Budget at least 1A for the smallest servo, it only gets bigger with larger servos or high torque servos.
95% of servo problems here is inadequate power.

Your problem would seem to be that you have the wrong sort of "servo". You have a continuous rotation servo, which of course is exactly what your link tells you. These have NO positional control, you can make them turn one way, the other way and stop. That's it.

If you want positional control you need a standard servo like almost all the others that Pololu sell.


Oh of course! I knew it would be something glaringly obvious like this, my brain was not in gear yesterday. Cheers :slight_smile:

And its very annoying that they call them continuous rotation servos, they are not servos at all,
just motors with integrated drivers.

It's even worse when they call them 360 degree servos and don't even mention that they are continuous rotation things.


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