Tower pro sg-5010 servo problem


First of all, I'm a total noob in both arduino and electronics, so please forgive me stupid questions :)

I have 3 tower pro sg-5010 servos and I want to control them with arduino. For start, I just uploaded servo example from sketches and connected the servo. Arduino restared (and my USB port was dead for some time) so I decided to have an external power source.

So I did and now I have a router transformator (it says: OUTPUT: 5V-=-=2A). I connected it to a servo and tried to control it with arduino but I got only some random small, fast random moves. Doing just one intruction per run, like:

void loop() { myservo.write(10); delay(15000); }

Also brings me small random moves. What is the problem? Is the power supply bad? I guess the servo is ok because all 3 I have behave in the same way.

Haalp :) njn

Did you collect the grounds (0V) together?

I did and it works! Thanks!

I’m a bit of a novice also, so you’re not the only one :stuck_out_tongue: :wink:

what do you want to do with the servo exactly?

If you want the servo to just sweep, they have example code here

But from looking at your code, I assume that you have defined your “int” because you have movement. You have delay set at 15000ms which is 15 seconds.

Well going from the example I posted the link from, just looking at the actual operation, I’l try to help define what each step is doing so, you can understand and write your own code.

void loop()
is just the start of the set of instructions. Usually anything before that is just to set where the inputs/outputs are and start position.

"for(pos = 0; pos < 180; pos +=1)
Says if position is 0 or less than 180, then raise by 1 position, until 180 is reached.

myservo is the NAME of the servo you gave the servo. write means set the pin you defined as “myservo”. (pos) is the position calculated.

is the wait time until the start of the next operation.

the rest is the same but calculation is reversed (counting down instead of counting up).

Like to note that the positions of where the “{” and “}” define the start and stop of a sub-operation .

Hi The Question,

Thanks for explaination. Programming is my job, so I have no problem the code but I'm sure your post will help others.

As for the language, you might want to check processing ( There are some some really nice tutorials which will help you at the beginning.