#include <LiquidCrystal_I2C.h>
const int potPin = 33;
const int servoPin =32;
const int Canal = 0;
const int frecuencia = 50;
const int resolucion = 8;
int servoPos;
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
void setup() {
LCD.init();
LCD.backlight();
LCD.setCursor(0, 0);
pinMode(servoPin, OUTPUT);
ledcAttachPin(servoPin, Canal);
ledcSetup(Canal, frecuencia, resolucion);
ledcWrite(0,12);
}
void loop() {
int potValue = analogRead(potPin);
servoPos = map(potValue, 0, 4095, 0, 180);
int dutyCycle = map(servoPos, 0, 180, 6, 32);
ledcWrite(Canal, dutyCycle);
LCD.setCursor(0,0);
LCD.print("Pos: ");
LCD.print(servoPos);
delay(100);
}