hi,
(just take the wiring from wiring and the code from arduino)
as i understand, a standard servo motor has three pins.
-> Vdd (power)
-> Ground
-> control pulse
the easiest way (READ THE NOTE AT THE END) would be to connect Vdd to 5V out on arduino and ground to ground. (assuming that your servo is ok with 5V. check the manual! )
-> now your servo gets power but will not move yet. you will have to send "pulses" to it, which tell motor in which direction it should move.
so the third pin (control pulses) from your servo goes to a digital out of your arduino. lets call it servoPin, like in the code.
a pulse means a signal which is determined by its length. between pulses there is a small pause (20ms in the code example).
let's say pulses(power HIGH) are dashes (-) and pauses(power LOW) are dots(.):
if you pulse .-.-.-.-.-.-.-.-.-.- your servo motor will move to the left.
if you pulse .----.----.----.----.----.----. on servoPin your motor will turn to the right.
if you pulse .----.----.----.-.-.-.-.-.-.-. your servo will first move to right and then to left.
it's a quite simple concept: short pulse->left , long pulse->right
the exact timing depends on your servo.
NOTE:
motors tend to draw a lot of current just before starting to move. YOU SHOULD NOT take the Power directly from arduino, since this behaviour could interfere with the internal computing on your board.
you can do so for testing purposes on your own risk as i don't think that this could do much harm to the board. you just can't be sure that it will work properly.
if you're taking power from an external source, just make sure that both grounds (arduino and external source) are both connected to your motor.
and as always: someone please correct me if i'm wrong
best, kuk