Servo sweep tweeks

Hi there,

I am playing around with the Servo sweep codes. How do I code it so that the servo makes a complete stop for #(seconds) before continuing its motion to reach the next position?

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

thanks,

Tom

delay(1);                      // waits 15ms for the servo to reach the position Nope.

Please remember to use code tags when posting code.

How do I code it so that the servo makes a complete stop for #(seconds) before continuing its motion to reach the next position?

If you're happy with using delay (), then use that. Remember, 1000 milliseconds in a second.

pause = 2000; // two seconds delay
void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position corrected
  }
   delay(pause);
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  delay(pause)
}

The delay(15) is a bit short for the servo's movement try changing that.

thanks for the tip Grumpy_Mike,

but its shows error message for pause = 2000;

windchase:
but its shows error message for pause = 2000;

Yes it will because you have not declared it. Prefix that with an int