#include <LiquidCrystal_I2C.h>
float pot = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int sliderPin = A1;
const int potPin = A0;
String nome = "Joao";
String curso = "Dev";
void setup() {
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(3, OUTPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Boa Noite");
Serial.begin(115200);
delay(5000);
lcd.clear();
}
void loop() {
pot = analogRead(potPin);
float volts = pot * 0.0048875;
Serial.println(volts);
lcd.setCursor(2, 0);
lcd.print(volts);
int sliderValue = analogRead(sliderPin);
int potValue = analogRead(potPin);
int delayTime = map(potValue, 0, 1023, 100, 1000);
if (sliderValue < 512) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(nome);
for (int position = 0; position <= 16 - nome.length(); position++) {
lcd.clear();
lcd.setCursor(position, 0);
lcd.print(nome);
delay(delayTime);
}
} else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(curso);
for (int position = 0; position <= 16 - curso.length(); position++) {
lcd.clear();
lcd.setCursor(position, 0);
lcd.print(curso);
delay(delayTime);
}
}
}