Servo Motors

Hi guys,

I’m working on a project and I’m trying to control how many rotations and how fast the servo turns but I can’t seem to get it to work. This is my script so far:

#include <Servo.h>

Servo myservo;
int servoPin=9;
int sangle=0;

void setup()

void loop()


What am I missing? I’m new to arduino and have no idea what’s wrong. Please help.

well for one thing the parameter for write() has to be in the range 0-180.
try only using the values 45 and 135, changing every few seconds.
this yields a pulse width that alternates between 1.75 ms and 2.25 ms

oops my bad I didn't notice you're not overriding the pulse width limits in your attach(), which you probably need to do... for now

try attach(servoPin, 1600, 2400);

Hey wg0z,

i’m not sure what you mean. I’m very new to all of this and only have been using this for a few weeks. Right now, I’m still trying to figure out how to control how many rotations the motor turns. If you could tell me where my script has gone wrong and what I need to change to make that work, I’d greatly appreciate it.


Rotations?? A regular servo only moves withing 180 degrees.

Do you have a "continuous Rotation Servo"??

You need to point to a link about the servo you have..

More overall Servo information HERE:

you cant really measure/control rotations for a so-called continuous-rotation servo without extra hardware; there's typically no feedback and exact RPM control isn't really possible. maybe you need a stepper motor.