Servo Problem

I'm new to Arduino things, and I've just got myself an Arduino Uno. I'm using the example servo code that comes in the Arduino application. So basically I'm using a potentiometer on input A0, and then mapping that to a value of between 0 and 255 for the analog output PWM on pin 9. I've checked over and over that I have cables in the right place. I've checked the serial message box thing that the value of the potentiometer is always between 0 and 255. I've checked the wiring over and over, and I've tried using several different servos but all have the same problem. The servo doesn't respond to any change of the potentiometer, and it just jitters violently and heats up rather fast. To my understanding, the output pin (9 in this case) is supposed to change the duty cycle, between full-duty and no-duty depending on the 0 to 255 input from the potentiometer. When output to a servo, the servo should react by turning to an appropriate angle. Am I doing anything wrong?

If you use a regular hobby RC-Servo and don't use the Servo library but some PWM output, throw your program away and try again with the Servo Library. If you use the Servo Library, post your code.


Hi, I’m using this example code:

#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 

That code doesn't match your description in your first post. Have you changed stuff, or does that code still not work?

To my understanding, the output pin (9 in this case) is supposed to change the duty cycle, between full-duty and no-duty depending on the 0 to 255 input from the potentiometer

That's not how an R/C servo works.

I have tried the previous code and I’ve tried using analog signals without the servo library. Neither are working. If that is wrong, how does an R/C servo work?

I've tried using analog signals without the servo library

The Arduino doesn't have any "analogue signals", and R/C servos use PPM, not the PWM signals generated by an Arduino analogWrite.

Did you connect the grounds?

What is the difference between PPM and PWM signals for a servo? I meant the analogWrite function when I said analog signals. My mistake. The grounds are all connected. Although, I'm using power and ground from a breadboard for the servo, as the Uno doesn't have enough power pins. This shouldn't make a difference though, right?

What's the difference? Duty cycle and about a concert A.

Concert A?

440Hz is the servo I'm using. What else could I be doing wrong?

Duty cycle and about a concert A


You servo look like a fairly standard Futaba 3003 clone. There is no reason I can think of it shouldn't work with the servo library.

myServo.write (map (analogRead (potPin), 0, 1024, 0. 180));

I've used the Serial.println function to check that the potentiometer is giving a correct value, and if I use analogRead on the servo signal pin (not sure if you supposed to do that for an output), it gives me values between 0 and about 920, depending on what the potentiometer is doing. Which seems kind of strange. Also, my servo just made a loud crack and is very hot and now I can't turn it even when the power is off. Although I have more, so I'll keep trying. The servo doesn't seem to respond at all to the change in value from the potentiometer.

Don't do an analogRead on a digital signal, it'll just confuse you. Ok looks like you've broken that servo, so stick with the simple servo library stuff and try a new one. Do NOT use analogWrite to drive a servo.

Fixed it! I have no idea why, but attaching the servo to the 3.3v pin makes it work perfectly. Anyone know why this might be?

Most servos are 4.8V minimum, so no, no idea. What was it connected to before?

The 3.3V pin isn't specced to drive a servo