#include <ESP32Servo.h>
const int servoPin = 18;
const int button=33;
int buttonstate =0;
Servo servo;
void setup() {
servo.attach(servoPin);
pinMode(button, INPUT_PULLUP);
}
void loop() {
buttonstate = digitalRead(button);
if (buttonstate == 1)
{
servo.write(90);
delay(1000);
}
else
{
servo.write(0);
delay(1000);
// servo.write(0);
// delay(1000);
}
}