#include <ESP32Servo.h>
#include <stdio.h>

Servo servo1;  // create servo object to control a servo
// twelve servo objects can be created on most boards

Servo servo2;

int pos = 0;    // variable to store the servo position
int state = 1;
bool done = false;

void setup() {
  servo1.attach(18, 500, 2400);  // attaches the servo on pin 13 to the servo object
  servo2.attach(32, 500, 2400);
  pinMode(2, INPUT);

}

void loop() {

if(done==false){
  state = digitalRead(2);
}

if(state==1){
    for (pos = 90; pos >= 45; pos -= 1) { // goes from 0 degrees to 180 degrees
      // in steps of 1 degree
      servo1.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
    }
    for (pos = 90; pos >=70 ; pos -= 1) { // goes from 180 degrees to 0 degrees
      servo2.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
    }
    done = true;
    state = 0;
}


}