#include <ESP32Servo.h>
const int Pin = 14;
const int pin2 = 21;
const int button = 27;
const int pin3 = 18;
int state = 0;
Servo motor;
void setup() {
Serial.begin(1); 
motor.attach(Pin);
pinMode(button,INPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3,OUTPUT);
digitalWrite(pin3,HIGH);
}
void loop() 
{
  int state = digitalRead(button);
  for(int deg=90;deg<=180;deg++){
  if(state == HIGH){
  digitalWrite(pin3,LOW);
  digitalWrite(pin2,HIGH);
  motor.write(deg);
  delay(20);
  for (int deg=180;deg>=90;deg--){
  motor.write(deg);
  delay(10);
  }
  }
  digitalWrite(pin2,LOW);
  digitalWrite(pin3,HIGH);

}
//Serial.println(deg);