#include <ESP32Servo.h>
Servo servo1;
int minUs = 500;   //0度是脉宽,单位us
int maxUs = 2500;  //180度脉宽,单位us
int servo1Pin = 15;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  ESP32PWM::allocateTimer(0);  //指定使用的硬件定时器 esp32有4个
  servo1.setPeriodHertz(50);   //指定PWM频率
  servo1.attach(servo1Pin, minUs, maxUs);
  servo1.write(90);  //转到指定角度(0-180);
  servo1.detach();   //不需要的时候将引脚和ledc分离
}

void loop() {
  // put your main code here, to run repeatedly:
}
