Hey guys,
So I am planning to use the arduino mega 2560 for a project I am doing. I am confused on one thing though. I will be using servos and have gone through the servo library. However, I know that code is read by the controller line by line. So Even though I know how I want to move my servos I dont know how/if you can move 2 servos at the same time. For example if I wanted to move servo 1 to 45 degrees and servo 2 to 45 degrees (both from zero) I could write.
#include <SoftwareServo.h>
SoftwareServo myservo; // create servo object to control a servo
void setup()
{
myservo1.attach(2); // attaches servo1 on pin 2 to the servo object
myservo2.attach(3); // attaches servo2 on pin 3 to the servo object
}
void loop()
{
myservo1.write(600); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
myservo2.write(600); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
SoftwareServo::refresh();
}
But this would move servo 1 followed by servo 2. How would I move them both simultaneously? Thanks
P.S. Code is just an example and not meant to be functional.