#include <ESP32Servo.h>
#define freq 2000
#define channel 0
#define resolution 7
#define led 12
#define servoPin 14
Servo servo;
int pos = 0;
void setup() {
ledcSetup(channel,freq,resolution);
ledcAttachPin(led,channel);
servo.attach(servoPin, 500, 2400);
}
void loop() {
for(int i=0;i<180;i+=1)
{
servo.write(i);
ledcWrite(channel,i);
delay(15);
}
for(int i=180;i>=0;i-=1)
{
servo.write(i);
ledcWrite(channel,i);
delay(15);
}
}