Modify Sweep Program to Control Servomotor's Position

Hi All,
I am a newbie in Arduino programming. Yesterday, I got my Arduino and Futaba hobby servomotor. I tried the sweep program in Arduino and it works right. My question is that is it possible to modify the sweep code such that the loop of servomotor to go from position A to position B will only run for x number of minutes then it will stop at specific position such as position A? I am not sure if this is even possible. I tried to research but most of what I've seen related topics are open-ended question and was never answered. Appreciate any input/advice how can I proceed.

Thanks

I tried the sweep program in Arduino and it works right.

Well, post what you have so far.

Read this before posting a programming question

... is it possible to modify the sweep code such that the loop of servomotor to go from position A to position B will only run for x number of minutes ...

Yes.

But before you ask why it doesnt work anymore, read the two links below.

Duane B

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

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 = 45; pos < 135; pos += 1) // goes from 45 degrees to 135 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
}
for(pos = 135; pos>=45; pos-=1) // goes from 135 degrees to 45 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

Is there another library aside from servo.h that I could use?

Is there another library aside from servo.h that I could use?

For what purpose? There is a SoftwareServo library, but it's a pain to use, as you have to programmatically keep refreshing each servo so that it will hold position, unlike the standard servo library that does automatic refreshing.

http://www.arduino.cc/playground/ComponentLib/servo

The standard servo library supports 12 servos, not the 8 that you have in your comments.

I have a library that supports servos on every Arduino pin which is realistically 18 allowing for serial coms.

I have another library that will get you 20 from four pins using a little bit of additional hardware.

I would still recommend the servo library though its well understood and widely used and has no problems that I am aware of.

Duane B

rcarduino.blogspot.com