servo shake

Hey, I am using servos to make a robotic arm, and I cant get the servos to stop shaking. Even just the servo itself sometimes shakes. I am unable to fix this, and I am controlling the servos with potentiometers. Here is my code:

#include <Servo.h>
Servo myservo; // create servo object to control a servo
int servoPin = 3; // define the pin of servo signal line
int potPin = 0; // analog pin used to connect the potentiometer
int potVal; // variable to read the potValue from the analog pin
void setup() {
 myservo.attach(servoPin); // attaches the servo on servoPin to the servo object
}
void loop() {
 potVal = analogRead(potPin); // reads the potValue of the potentiometer
 potVal = map(potVal, 0, 1023, 0, 180);// scale it to use it with the servo
 myservo.write(potVal); // sets the servo position
 delay(15); // waits for the servo to get there
}
In the cod

Shake? Do you mean jitter or oscillation?
Cheap servos are not terribly precise and may oscillate a bit and not stay at a fixed set point.

If it happens only at maximum/minimum try reducing the range, for example try 5-175 instead of 0-180.

Servo jitter is almost always a servo supply problem.
The supply must be able to deliver the STALL current of ALL servos.
Leo..

Hi,
What is the power supply for the servos?

Thanks... Tom.... :slight_smile:

If you are trying to power the servo from the Arduino 5V pin, THAT is the problem.

A 4xAA battery pack will usually work for one or two servos, but plan on at least 1 Ampere per servo. Be sure to connect all the grounds.