#define COUNT_LOW 0
#define COUNT_HIGH 8888
#define TIMER_WIDTH 16
#include "esp32-hal-ledc.h"
void setup() {
Serial.begin(9600);
ledcSetup(1, 50, TIMER_WIDTH); // channel 1, 50 Hz, 16-bit width
ledcAttachPin(18, 1); // GPIO 18 assigned to channel 1
}
void loop() {
for (int i=COUNT_LOW ; i < COUNT_HIGH ; i=i+100)
{
ledcWrite(1, i); // sweep servo 1
Serial.print(1,i);
delay(50);
}
for (int i=COUNT_HIGH ; i > COUNT_LOW ; i=i-100)
{
ledcWrite(1, i); // sweep servo 1
Serial.print(1,i);
delay(50);
}
}