#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP32Servo.h>
Servo servo;
#define pot 14
#define serv 13
LiquidCrystal_I2C lcd(0x27, 16, 2);
bool x = true;
byte degreeSymbol[8] = {
B01110,
B01010,
B01110,
B00000,
B00000,
B00000,
B00000,
B00000
};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pot, INPUT);
servo.attach(serv, 500, 2500);
Serial.println("Hello, ESP32!");
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Hola, ESP32!");
lcd.createChar(0, degreeSymbol);
}
void loop() {
if (x == true) {
delay(1000);
lcd.clear();
x = false;
}
int valor = analogRead(pot);
int place = map(valor,0,4095,0,180);
Serial.println(valor);
servo.write(place);
lcd.setCursor(0,0);
lcd.print("Posicion : " );
lcd.setCursor(12,0);
lcd.print(" ");
lcd.setCursor(11,0);
lcd.print(place);
lcd.setCursor(14,0);
lcd.write((uint8_t)0);
delay(20);
}