#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int voltage;
double output;
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
lcd.setCursor(5, 0);
voltage = analogRead(A0);
output = (double) voltage * 5 /1023;
lcd.print(output);
lcd.setCursor(10, 0);
lcd.print("V");
}
void loop() {
// put your main code here, to run repeatedly:
int val;
val = analogRead(A0);
if(val != voltage){
voltage = val;
lcd.clear();
lcd.setCursor(5, 0);
output = (double) voltage * 5 /1023;
lcd.print(output);
lcd.setCursor(10, 0);
lcd.print("V");
}
}