int PWM_FREQUENCY = 1000; // this variable is used to define the time period
int PWM_CHANNEL = 0; // this variable is used to select the channel number
int PWM_RESOUTION = 8; // this will define the resolution of the signal which is 8 in this case
int GPIOPIN = 15 ; // GPIO to which we want to attach this channel signal int dutyCycle = 127; // it will define the width of signal or also the one time
int dutyCycle = 255; // it will define the width of signal or also the one time
int pot = 34; // pino ligado ao cursor do potenciometro
int leitura=0; //variavel para armazenar a leitura do potenciometro
void setup()
{
ledcSetup(PWM_CHANNEL, PWM_FREQUENCY, PWM_RESOUTION);
ledcAttachPin(GPIOPIN, PWM_CHANNEL);
Serial.begin(9600);
}
void loop()
{
leitura = analogRead(pot);
Serial.println(leitura);
leitura = map(leitura, 0, 4095, 0, 255);
ledcWrite(PWM_CHANNEL, leitura);
}