#include <ESP32Servo.h>
Servo myservo;
int pos = 0;
void setup(){
myservo.attach(21);
pinMode(5, INPUT_PULLUP);
pinMode(18,INPUT_PULLUP);
Serial.begin(9600);
}
void loop(){
if(digitalRead(5)==LOW)
{
pos++;
Serial.println(pos);
myservo.write(pos);
delay(15);
if(pos>=180)
pos=180;
}
if(digitalRead(18)==LOW)
{
pos--;
Serial.println(pos);
myservo.write(pos);
delay(15);
if(pos<=0)
pos=0;
}
}