#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Mengatur alamat I2C LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
//initialize serial communication at 9600 bits persecon:
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("Ampere");
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
//convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5)
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(sensorValue);
Serial.println(voltage);
// Menampilkan nilai sensor dan tegangan ke LCD
lcd.setCursor(0, 0);
lcd.print("Ampere: ");
lcd.print(sensorValue);
lcd.setCursor(0, 1);
lcd.print("Voltage: ");
lcd.print(voltage);
delay(500);
}