#define LED_PIN 2
#define POT_PIN 34
#define PWM_FREQ 5000
#define PWM_RES 8 // 8 bits --> 0 to 255
void setup() {
// Serial.begin(115200);
// Serial.println("Hello, ESP32!");
ledcAttach(LED_PIN, PWM_FREQ, PWM_RES);
}
void loop() {
int potVal = analogRead(POT_PIN); // 0 to 4095
int dutyCycle = potVal / 16; // 0 to 255
// Serial.println(dutyCycle);
ledcWrite(LED_PIN, dutyCycle);
delay(20);
}