#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
#define pinAdc 34
unsigned int Nilai_Adc;
float Tegangan;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
LCD.init();
LCD.backlight();
LCD.setCursor(0, 0); // x,y
LCD.print("Adc: ");
LCD.setCursor(0, 1); // x,y
LCD.print("Teg: ");
}
void loop() {
// put your main code here, to run repeatedly:
Nilai_Adc =analogRead(pinAdc);
Tegangan = Nilai_Adc * (3.3/4095);
LCD.setCursor(5,0);
LCD.write((Nilai_Adc/100) + 0x30);
LCD.write(((Nilai_Adc/10)%10) + 0x30); // 246/10 = 24%10 = 4
LCD.write((Nilai_Adc%10) + 0x30);
LCD.setCursor(5,1);
LCD.write((Tegangan/10) + 0x30); // 246/10 = 24%10 = 4
LCD.write(',');
LCD.write((Tegangan%10) + 0x30);
delay(100); // this speeds up the simulation
}