#define LED 23
#define pot 13
const int freq = 5000; //set the PWM freq to 5000Hz
const int ledChannel = 0; //PWM channel 0-15
const int resolution = 10; //Resolution 8, 10, 12, 15
void setup() {
// put your setup code here, to run once:
// configure LED PWM functionalitites
ledcSetup(ledChannel, freq, resolution);
// attach the channel to the GPIO to be controlled
ledcAttachPin(LED, ledChannel);
}
void loop() {
// put your main code here, to run repeatedly:
int x = map(analogRead(pot), 0, 4095, 0, 1023); //map the input resolution to output resolution
ledcWrite(ledChannel, x); //write the PWM value to GPIO pin
delay(1000); //Delay 1 second
}