Ich habe ein Servo, das von 0 bis 180 Grad dann zurück zu 0 fegt, aber ich kann die Funktion delay() nicht verwenden, wie ich die Wobbelung durch einen Bewegungssensor unterbrochen werden muss. Ich habe etwas Code geschrieben, aber der Sweep ist nicht glatt, der Servo springt manchmal herum. Was habe ich nicht richtig gemacht? Vielen Dank im Vorausarduino Servo und Verzögerung
int x = 0;
void pivot(){
for (pos = 0; pos <= 180; pos += 5) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo_2.write(pos); // tell servo to go to position in variable 'pos'
//delay(15);
for (x; x<10; x++)
{
delay(1);
ping();
}
x=0;
}
for (pos = 180; pos >= 0; pos -= 5) { // goes from 180 degrees to 0 degrees
myservo_2.write(pos); // tell servo to go to position in variable 'pos'
//delay(15);
for (x; x<10; x++)
{
delay(1);
ping();
}
x=0;
}
}