#include <ESP32Servo.h>
const int button1_pin = 32;
const int button2_pin = 33;
const int button3_pin = 14;
const int servo_pin = 13;
Servo myServo;
int pos = 90;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(button1_pin, INPUT_PULLUP);
pinMode(button2_pin, INPUT_PULLUP);
pinMode(button3_pin, INPUT_PULLUP);
myServo.attach(servo_pin);
}
void loop() {
bool button1 = !digitalRead(button1_pin);
bool button2 = !digitalRead(button2_pin);
bool button3 = !digitalRead(button3_pin);
if(button2 == HIGH)
pos = 90;
if(button1 == HIGH)
pos++;
if(button3 == HIGH)
pos--;
if(pos > 180)
pos --;
if(pos < 0)
pos ++;
myServo.write(pos);
Serial.print("Button 1: ");
Serial.print(button1);
Serial.print(", Button 2: ");
Serial.print(button2);
Serial.print(", Button 3: ");
Serial.print(button3);
Serial.print(", Angle of servo: ");
Serial.println(pos);
delay(15);
}