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.
... 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 ...
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.