Trembling Mini Servos

Hello All, been working on a small project with two mini servos.

The Joystick controls both servos, left and right. When in the neutral position, the x-axis servo trembles. That is to say it seems like it is getting input from the Joystick and it seems to tremble back and forth a little. This is undesirable as I want the laser to sit perfectly still. Below is a link so you can see and hear it in a video.

Also here is the code.

Any light anyone could shed would be greatly appreciated!

#include <SoftwareServo.h>

SoftwareServo myservo;
SoftwareServo myservo1; // object to control a servo

int x,y,z;

boolean light_on = false;
int reading = 0;

void setup()


// Serial.begin(9600);
pinMode(3, OUTPUT); //pin 3 digital laser out (black to red BB)
pinMode(7, INPUT); // z COM port white to grey com port 7


void loop()

if(light_on == true)
digitalWrite (3, HIGH); // turn the light on!
if(light_on == false) // turn the light off!
digitalWrite (3, LOW);

reading = digitalRead(7); // check the value of the z input on the joystick.

if (reading == 1)
light_on = ! light_on;
reading = 0;


x = analogRead(0);
x = map(x, 0, 1023, 0,180 );
y = analogRead(1);
y = map(y, 0, 1023, 0, 179);




Is there a specific reason you are using SoftwareServo, rather than the regular Servo library?

That is a good question! I'm not sure why I initially chose to go that path, I'm going to try using this library and see if it rectifies my problem. Thanks for the suggestion!

Say it isn't an input issue but more so a noise issue. I haven't done much in the servo world, although I know in the LED world, if we have some flicker, we put a small value capacitor before the led to get rid of that. So maybe that'll work here?

What is the Arduino reading from the joystick? If that value is not stable the servo won't be stable.

Is the servo under load? what you might be hearing is the servo working to hold position. Output the joystick value and the value you are outputting to the servo to see what is happening.

Noise in = noise out.

Two great suggestions, thanks I will try that. I'm using a standard little joystick I ordered from China, similar to a PS2 controller stick. It seems to be stationary but I will investigate further as this seems like a likely culprit!