// put your setup code here, to run once:
#include <Servo.h>
int POSservo = 0;
Servo myservo1; // create servo object to control a servo
Servo myservo2; // create servo object to control a servo
Servo myservo3; // create servo object to control a servo
Servo myservo4; // create servo object to control a servo
Servo myservo5; // create servo object to control a servo
Servo myservo6; // create servo object to control a servo
void setup()
{
myservo1.attach(3);
myservo2.attach(5);
myservo3.attach(6);
myservo4.attach(9);
myservo5.attach(10);
myservo6.attach(11); // power pin connected to pin 5 of Arduino board
// Here, the pin of the Arduino board connected to the servo should be a PWM pin
}
void loop()
{
// It will sweep the servo from 0 to 180 degrees
for (POSservo = 0; POSservo <= 90; POSservo=POSservo+1)
{
// tell servo to go to position in variable 'POSservo'
myservo1.write(POSservo);
myservo3.write(POSservo);
myservo5.write(POSservo);
// It will wait for the specified duration (20 milliseconds) to reach the position
delay(30); // delay of 15 millisecond(s)
}
for (POSservo = 90; POSservo >= 0;POSservo= POSservo-1)
{
// It will tell servo to go to position in the declared variable 'POSservo'
myservo2.write(POSservo);
myservo4.write(POSservo);
myservo6.write(POSservo);
delay(30);
// we can modify the duration as per the requirements
}
}