help with servo motors?

hello,

i used the servo library and it works fine!
i tried to analyse the code in wich was written i didnt get it!!!
so i need a sample code for driving a servo ??
something wich i could understand easily using for loops and delays only !.

thanks alot , appreciate your help.

R/C servos generally use a positive pulse between 1ms and 2ms wide (0..approx 180 degrees), repeated every 20ms.

If you express these times as 1000us, 2000us and 20000us, you should be able to write a simple "loop ()" using "delayMicroseconds", "digitalWrite" and a couple of variables to set the position of a servo on any single pin.
Don't forget to set the pin as an output in "setup ()".

thank you groove. appreciate your help
can you write me a sample code on what you said !! i'm new on the arduino ?

Caveat: Untested.

const int servoPin = 2;

const unsigned int minPulse = 1000;
const unsigned int maxPulse = 2000;
const unsigned int pulseRepeat = 20000;

unsigned int servoPos = (maxPulse + minPulse) / 2;

void loop ()
{
  pinMode (servoPin, OUTPUT);
  digitalWrite (servoPin, LOW);
}

void setup ()
{
    digitalWrite (servoPin, HIGH);
    delayMicroseconds (servoPos);
    digitalWrite (servoPin, LOW);
    delayMicroseconds (pulseRepeat - servoPos);
}

thank you groove

Expanding to use a potentiometer to control the servo:

const int servoPin = 2;
const int potPin = 0;   // analogue pin zero.

const unsigned int minPulse = 1000;
const unsigned int maxPulse = 2000;
const unsigned int pulseRepeat = 20000;

unsigned int servoPos = 0;

void loop ()
{
  pinMode (servoPin, OUTPUT);
  digitalWrite (servoPin, LOW);
}

void setup ()
{
    servoPos = map (analogRead(potPin), 0, 1023, minPulse, maxPulse);
    digitalWrite (servoPin, HIGH);
    delayMicroseconds (servoPos);
    digitalWrite (servoPin, LOW);
    delayMicroseconds (pulseRepeat - servoPos);
}

y is the code written in void setup not in void loop?

Oops!
You're right, of course.
Like I said - untested.
(too much Bushmills)