/*
Proyecto LCD con servomotor
Prof. Luis Orozco
*/
#include <Servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Servo myservo;
const int potPin = A0;
int potVal;
int angle;
void setup() {
myservo.attach(9);
lcd.begin(16, 2);
lcd.print("ANGULO SERVO:");
}
void loop() {
potVal = analogRead(potPin);
angle = map(potVal, 0, 1023, 0, 180);
myservo.write(angle);
// Actualiza la pantalla LCD
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(angle);
lcd.print(" grados");
delay(20);
}
///////https://wokwi.com/projects/454669945588933633