Here is one of my codes, which I tried to use:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup()
{
myservo.attach(6); // attaches the servo on pin 9 to the servo object
}
void loop()
{
myservo.write(180);
}
And wiring is here:
Servo:
Yellow -- Arduino pin 6
Red -- pwr supply 6v +
Black -- pwr supply gnd
Arduino:
pin6 -- Servo
gnd -- pwr supply gnd
usb -- pc