servo sketch basics

Can anyone supply a general servo sketch for a 2560 Mega Arduino board. I have variables "A", "B", "C","D" and "E" that I would like to change to different values, to meet my needs. The standard sweep sketch in Arduino is not sufficiently flexible for my needs.

1/ a continuous sweep of the servo between angle "A" degrees to angle "B" degrees (and back to angle "A" then to angle "B" etc etc) in a continuous loop. For example the angle may be something like "A" = 20 degrees and "B" = 95 degrees. I need to input different values (on a trial basis) of angle "A" and angle "B" to get a mechanism attached to the servo, correct.
2/ the servo should move more slowly than normal. One way may be to have a given pause "C" miliseconds between small 1 degree (say) steps of the servo, while traversing between angle "A" and angle "B" and vice versa. I will need to trial different values of "C" to get a mechanism attached to the servo, correct.
3/ pause for "D" miliseconds when angle "B" is reached. For example, I may like to have a total traverse time between "A" and "B" of exactly 7.5 seconds.
4/ pause for "E" milliseconds when angle "A" is reached. For example, I may like to have a total traverse time between "B" and "A" of exactly 8.0 seconds.

I have looked at many requests for assistance with servo sketches, and the above one should satisfy most of them.

Challenge for some clever programmer...and keep us casual users very happy.

elsie008:
Can anyone supply a general servo sketch for a 2560 Mega Arduino board
....

Challenge for some clever programmer...and keep us casual users very happy.

...uh, what?

You just expect us to write your program for you because you can't take 20 min to do some quick googling and 20 more min to do some testing?

If you have a specific problem or need some general guidance, that's different.

Next time you make a post like this, do it in the "Gigs and Collaborations" section like you should've done from the start.

Start at File->Examples->Servo->Sweep
Add and modify delays where desired.

#include <Servo.h>
Servo myservo;  // create servo object to control a servo

const int A = 20;
const int B = 95;
const unsigned long C = 15;  // Milliseconds between steps
const unsigned long D = 123;  // Millisecond pause at position B
const unsigned long E = 456; // Millisecond pause at position A

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

void loop() {
  for (int pos = A; pos <= B; 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(C);                       // waits 15ms for the servo to reach the position
  }
  delay(D);
  for (int pos = B; pos >= A; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(C);                       // waits 15ms for the servo to reach the position
  }
  delay(E);
}

and keep us casual users very happy.

I utterly detest this kind of post.
Thread locked.
Take it to gigs.