#include <ESP32Servo.h>
Servo myservo1; // create servo object to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
int pos;
void setup() {
myservo1.attach(5); // set the control pin of servo 1 to 5
myservo2.attach(16); // set the control pin of servo 2 to 16
myservo3.attach(17); // set the control pin of servo 3 to 17
myservo4.attach(18); // set the control pin of servo 4 to 18
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
myservo1.write(pos); // tell servo to go to position in variable 'pos'
myservo2.write(pos);
myservo3.write(pos);
myservo4.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo1.write(pos); // tell servo to go to position in variable 'pos'
myservo2.write(pos);
myservo3.write(pos);
myservo4.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}
delay(1000);
}
void loop() {
myservo1.write(90);
myservo2.write(90);
myservo3.write(90);
myservo4.write(90);
}