yes, I'm new. Very impressed with these projects and applications and have several of my own I hope to share soon. BUT, I need help. I can not get the simple servo sketches to work. My servo will only move about 20 degrees. What am I doing wrong?

Not posting code and/or the schematic/pictures/etc of your setup...


hahah yeah that would indeed help.

What servos? What code?


And posted the wrong place too :wink:

But on topic, try adding an external power supply… While we don’t have any information, at all, about what you got, I assume that you just plugged it in USB, attached all the wires, and uploaded the program.


looks like a local path, use a picture upload service to store the image, then put that link in here

I have seen this happen with a digital servo like that one, whereas with a standard servo things worked OK - have you tried a standard servo?

I also noticed in some specs I pulled up on TowerHobbies that the neutral band is 1310us; I am not sure if this would be an issue with the library or not, but they mentioned on TowerHobbies that it would cause problems with certain older AM transmitters - they list the same thing at Futaba:

You may need to adjust the parameters of the library using the setMinimumPulse() and setMaximumPulse() methods. See:

You may also need to tweak the library directly. I can’t tell you much beyond that because I haven’t played with any of the digital servos yet…


How is this?

Just a comment on uploading images with flikr.

When you get to that page you can right click and view image (on firefox). You then get the image path rather than the page. Then you can use the [ img ] tags (3 from right), to embed the image directly in the post. Flikr also allows you to get the images in different sizes before upload by clicking 'all sizes' and then getting the path on each image. Like so:

Sorry I cannot help you on the servo problem though.


mwcintx, can you describe how the servo moves when you rotate the pot.

Perhaps try starting with the pot in the central position and see how much range you can get as you increase and decrease the pulse width starting from a level midway in the servos range.

You may want to add some code to the test sketch to display the pulse width on the serial monitor using the readMicroseconds method.

Strikes me you have 2 possible hardware problems. Your pot and your servo. You really should test one at a time. I'd eliminate the pot and modify the sketch to feed the servo values to make sure that's good. If so you know it's an analogue problem with the pot.

ClockworkRobot, if the OP printed the value on the serial monitor as suggested above, he can see if the pot is working or not.

If the value changes as expected but the servo doesn’t, the pot is ok. If the value doesn’t change as expected, the pot is not working correctly.

Isn't the pot not just a low-ohm value or so?

the pot should be between 5k and 20 k. What value did you use?

Do servos not stop at 60 degrees because of the design. You can modify them to go the ful 360.

The following sketch has two lines added which will print the servo value in microseconds.

#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 
void setup() 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
void loop() 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 

Make sure the baud rate in the serial monitor is set to 9600, or change the value in Serial.begin if you prefer to use a different rate.

Perhaps try: Serial.println(myservo.readMicroseconds(), DEC);

Characters are numbers too, have a look at an ascii table.. all characters have a corresponding decimal number, the DEC parameter forces it to convert the number into a string representation of the number. As opposed to seeing the number as a single character.

readMicroseconds returns an int – Serial.print will output this a number without needing the ',DEC' parameter.