const int potPin = 34;
int potValue = 0;
const int ledPin = 16; // 16 corresponds to GPIO16
const int freq = 5000;
const int ledChannel = 0;
const int ledChannel1 = 1;
const int resolution = 8;
void setup() {
Serial.begin(115200);
// configure LED PWM functionalitites
ledcSetup(ledChannel, freq, resolution);
ledcSetup(ledChannel1, freq, resolution);
// attach the channel to the GPIO to be controlled
ledcAttachPin(ledPin, ledChannel);
ledcAttachPin(18, ledChannel1);
}
void loop() {
// Reading potentiometer value
potValue = analogRead(potPin);
Serial.println(potValue);
map(potValue, 0, 4095, 0, 150);
ledcWrite(ledPin, potValue);
// // increase the LED brightness
// for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){
// // changing the LED brightness with PWM
// ledcWrite(ledChannel, dutyCycle);
// delay(15);
// }
// // decrease the LED brightness
// for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){
// // changing the LED brightness with PWM
// ledcWrite(ledChannel, dutyCycle);
// delay(15);
// }
ledcWrite(ledChannel1, potValue/16);
}