int led = 16;  
int pot = 2;


// configuração PWM
int freq = 5000; // 1 – 40MHz
int ledCanal = 0; // 0 – 15
int resolucao = 8;// 8 bits, podendo ser 1 - 16 bits

void setup() {
  pinMode(led, OUTPUT);
  // configuração das propriedades PWM p/ o LED
  ledcSetup(ledCanal, freq, resolucao);
  // anexando ao canal PWM
  ledcAttachPin(led, ledCanal);
  Serial.begin(115200);
  analogReadResolution(8);
}

void loop() {
  int valorPot = analogRead(pot);
  Serial.println(valorPot);
  ledcWrite(ledCanal, valorPot);
  delay(1000);
 
}