Trying control over servo motor without potenciometer

Hi guys!!!

I’m kind of newbie in Arduino, but I’m trying to control a servomotor without potenciometer…

Using blink example, I just modified a littlle bit that program… getting this…

int s=0;
int giroi =44;
int girod =30;
int pulso =10000;

void setup(){
  pinMode(giroi, OUTPUT);
  pinMode(girod, OUTPUT);
  Serial.begin(9600);
} 
void loop(){
 
if (s<=pulso){
  s = s+1;
  digitalWrite(girod,HIGH);
  delayMicroseconds(10);
  digitalWrite(girod,LOW);
  delayMicroseconds(10);
}
else if (pulso<s<=pulso*2);
{
  s = s+1;
  digitalWrite(giroi,HIGH);
  delayMicroseconds(10);
  digitalWrite(giroi,LOW);
  delayMicroseconds(10);
}
else
{
  digitalWrite(girod,LOW);
  digitalWrite(giroi,LOW);
}
}

So… what’s my problem?

1.- Delay gives me a relation between frequency and speed of servo… but reading about Arduino’s limitations I saw it only gives u 40 kHz… I need more than that… I don’t know how can I get it

2.- When variable pulso goes over 30000, my servo keeps spinning endless and I want to make my servo to turn right for a lap, then, second lap to turn left… I’m clueless…

Resume, I hope my servo can spin a few laps, as long as I can control how many laps, plus pulse and delay…

Sorry for my bad english…

Hoping your help…

Thanks…

PD: My servo has 2.6 A, 1.27 N*m, 220 V…

#7 below shows how to post code:

http://forum.arduino.cc/index.php/topic,148850.0.html

thanks zoomkat... it was very easy to fix it