# include <ESP32Servo.h>
Servo servo1;
Servo servo2;
// Servo servo3;
// Servo servo4;
const int servo1_pin = 18;
const int servo2_pin = 19;
void setup() {
Serial.begin(9600);
servo1.attach(servo1_pin);
servo2.attach(servo2_pin);
}
void spinServo (Servo object){
// Move from 0 to 180 degrees
for (int pos = 0; pos <= 180; pos += 1) {
object.write(pos);
delay(15);
}
// Move back from 180 to 0 degrees
for (int pos = 180; pos >= 0; pos -= 1) {
object.write(pos);
delay(15);
}
}
void loop() {
spinServo(servo1);
delay(15);
spinServo(servo2);
}