#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int potPin1 = A0;
const int potPin2 = A1;
const int potPin3 = A2;
const int currentDevider = 100;
const int lghtButton = 2;
const int backlightPin = 3;
int buttonState = 0;
int lastButtonState = HIGH;
int stringStart, stringEnd = 0;
int scrollCursor = 16;
void setup() {
pinMode(lghtButton, INPUT_PULLUP);
pinMode(backlightPin, OUTPUT);
lcd.begin(16, 2);
lcd.setBacklight(10);
String line1 = ". Made in SPINDO Karawang Factory by Jikun Mtc";
String line2 = "Loading...";
lcd.setCursor(0, 0);
lcd.print("SIGNAL ISOLATOR");
lcd.setCursor(5, 1);
lcd.print("TESTER");
delay(3000);
lcd.clear();
lcd.print(line1.substring(0, 16));
for (int i = 0; i <= line1.length() -0 ; i++) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(line1.substring(i, i + 16));
lcd.setCursor(0, 1);
lcd.print(line2);
delay(200);
}
delay(100);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Dikopian heula");
lcd.setCursor(0, 1);
lcd.print("biar fokus");
delay(2000);
lcd.setBacklight(0);
lcd.clear();
}
void loop() {
buttonState = digitalRead(lghtButton);
if (buttonState != lastButtonState) {
if (buttonState == LOW) {
if (digitalRead(backlightPin) == HIGH) {
digitalWrite(backlightPin, LOW);
lcd.setBacklight(0);
} else {
digitalWrite(backlightPin, HIGH);
lcd.setBacklight(10);
}
delay (50);
}
}
int potValue1 = analogRead(potPin3);
int potValue2 = analogRead(potPin2);
int potValue3 = analogRead(potPin1);
float voltage1 = potValue1 * (15.2 / 1023.0);
float current = potValue2 * (30.3 / 1023.0);
float voltage3 = potValue3 * (15.2 / 1023.0);
if(voltage1 > 9.99){
lcd.setCursor(2,0);
lcd.print(voltage1, 1);
}
else{
lcd.setCursor(2, 0);
lcd.print(voltage1, 2);
}
if(current > 9.99){
lcd.setCursor(2, 1);
lcd.print(current, 1);
}
else{
lcd.setCursor(2, 1);
lcd.print(current, 2);
}
if(voltage3 > 9.99){
lcd.setCursor(11, 0);
lcd.print(voltage3, 1);
}
else{
lcd.setCursor(11, 0);
lcd.print(voltage3, 2);
}
lcd.setCursor(0, 0);
lcd.print("X:");
lcd.setCursor(9, 0);
lcd.print("Z:");
lcd.setCursor(0, 1);
lcd.print("Y:");
lcd.setCursor(6, 0);
lcd.print("V");
lcd.setCursor(15, 0);
lcd.print("V");
lcd.setCursor(6, 1);
lcd.print("mA");
delay(100);
}