/*
Ligar um potenciometro a uma GPIO do ADC1 (10 bits) e ligar um led com valor
proporcional em uma GPIO com o PWM. Usar frequencia do PWM de 1 Khz e 8
bits de resolução.
*/
#define LED_PIN_1 2
#define POT_PIN 32
#define CH 7
#define DELAY 250
void setup() {
// Initialize the LED pin as an output
pinMode(LED_PIN_1, OUTPUT);
pinMode(POT_PIN, INPUT);
ledcAttachChannel(LED_PIN_1, 1000, 8, 0);
Serial.begin(115200);
}
void loop() {
int freq = map(analogRead(POT_PIN), 0, 4095, 0, 1023);
ledcWrite(LED_PIN_1, freq);//Escrevemos no canal 0, o duty cycle "i".
delay(50);
}