const int button = 13;
const int led = 2;
int count = 0;
int newcount;
#include <ESP32Servo.h>
const int servoPin = 12;
Servo servo;
void setup()
{
servo.attach(servoPin, 500, 2400);
Serial.begin(115200);
Serial.println("Hello you!");
pinMode(button, INPUT_PULLUP);
pinMode(led, OUTPUT);
}
void loop()
{
int buttonState = digitalRead(button);
if (buttonState == LOW)
{
newcount=count+1;
digitalWrite(led, !digitalRead(led));
Serial.print("pressed ");
Serial.println(newcount);
servo.write(count);
delay(250);
count=newcount;
}
if(count >=179)
{
count=0;
}
}