Help with servo project


I recently started a project where I will have to use and Arduino Micro to control a servo. But being a complete noob, after setting up a circuit for the servo, the servo doesn't seem to move after I compile and upload the example sweep program. I also made sure the correct board and serial port are selected. Did I forget to set anything in the program?

I took a couple of pictures of the circuit:

Thanks in advance for the help guys, and sorry if the question was too stupid.

Questions are never stupid, as they show the willingness to learn.

Can the Arduino deliver the power the servo's need? otherwise you must use a (power) transistor and a separate power supply for the servo's. In fact that is always a good idea.

Furthermore you can measure the signal with a multimeter (mandatory tool!) to check.

I hate to take issue with @robtillart, but there is no need for power transistors with a servo.

You do need to have a separate power supply for the servo as the Arduino can’t supply enough current unless the servo is very small AND has no load on it. If the servo draws too much power the Arduino will behave erratically which will probably appear like a software problem. Safest thing is to use a separate power supply. Just remember to connect the Arduino ground to the servo ground.

I can’t figure from your photos how things are connected. Can you post a photo of a clear drawing of all the connections.


A way to externally wire power to a servo.

Hey guys,

I don’t know if I changed anything but now I got it to work, thanks for the help!
On another note, messing around with the sweep example, I tried setting different angles (original was 180) but I noticed that the servo doesn’t go all the way to the angle, specially with angles below 100, and also, when setting the delay between each position, the servo goes above the set value.

Here is the code I’m trying right now (right now it almost goes all the way to 180 for some reason):

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
myservo.attach(9); // attaches the servo on pin 9 to the servo object

void loop()
for(pos = 0; pos < 110; pos += 1) // goes from 0 degrees to 110 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(30); // waits 30ms for the servo to reach the position
for(pos = 110; pos>=1; pos-=1) // goes from 110 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(30); // waits 30ms for the servo to reach the position

Sorry for the long post, but I couldn’t figure out why it isn’t working properly.

Thanks for the help again.

Servos are not precision devices and there will be variations between individual devices and between different models. Some can't physically sweep through 180 deg, some can go a bit more.

Your code should move the servo through 110 deg so I don't understand how you say it moves 180 deg.

Perhaps you mean that it goes all the way to the end stop at one end? In that case it probably isn't going all the way to the other end stop.