#include <LiquidCrystal.h>
#include <Keypad.h>
const int ROW_NUM = 4; // jumlah baris pada keypad
const int COLUMN_NUM = 4; // jumlah kolom pada keypad
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','=','D'}
};
byte pin_rows[ROW_NUM] = {7, 6, 5, 4}; // terhubung dengan pin-pins baris keypad
byte pin_column[COLUMN_NUM] = {3, 2, 1, 0}; // terhubung dengan pin-pins kolom keypad
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM);
LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // Sesuaikan pin LCD dengan koneksi di Arduino
float nilai = 0;
float liter, i;
float j = 0.00;
// Deklarasi nilai A, B, C, D
const float nilaiA = 25000;
const float nilaiB = 50000;
const float nilaiC = 100000;
const float nilaiD = 200000;
void showSplashScreen() {
lcd.setCursor(0, 1);
String message1 = "Kel. Mikrokontroler";
for (byte s = 0; s < message1.length(); s++) {
lcd.print(message1[s]);
delay(75);
}
lcd.setCursor(0, 2);
String message2 = "Program Pompa SPBU";
for (byte a = 0; a < message2.length(); a++) {
lcd.print(message2[a]);
delay(75);
}
delay(1500);
}
void setup() {
lcd.begin(20, 4);
showSplashScreen();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Total Rp : ");
lcd.setCursor(0, 2);
lcd.print("Liter : ");
lcd.setCursor(11, 1);
lcd.print(nilai);
}
void loop() {
char key = keypad.getKey();
if (key) {
if (key >= '0' && key <= '9') {
// Input angka
nilai = nilai * 10 + (key - '0');
lcd.setCursor(11, 1);
lcd.print(nilai);
}
else if (key == '=') {
// Enter
lcd.setCursor(0, 1);
lcd.print("Total Rp : ");
lcd.setCursor(0, 2);
lcd.print("Liter : ");
lcd.setCursor(11, 1);
lcd.print(nilai);
liter = nilai / 10000.0;
lcd.setCursor(11, 2);
lcd.print(liter, 2);
delay(1000);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Total Rp : ");
lcd.setCursor(0, 2);
lcd.print("Liter : ");
for (i = 0; i <= nilai; i += 500) {
lcd.setCursor(11, 1);
lcd.print(i);
lcd.setCursor(11, 2);
lcd.print(j += 0.05);
delay(50);
}
lcd.setCursor(11, 2);
lcd.print(liter);
}
else if (key == '*') {
// Reset
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Total Rp : ");
lcd.setCursor(0, 2);
lcd.print("Liter : ");
nilai = 0;
j = 0.00;
}
else if (key == 'A') {
nilai = nilaiA;
lcd.setCursor(11, 1);
lcd.print(nilai);
}
else if (key == 'B') {
nilai = nilaiB;
lcd.setCursor(11, 1);
lcd.print(nilai);
}
else if (key == 'C') {
nilai = nilaiC;
lcd.setCursor(11, 1);
lcd.print(nilai);
}
else if (key == 'D') {
nilai = nilaiD;
lcd.setCursor(11, 1);
lcd.print(nilai);
}
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
keypad1:R1
keypad1:R2
keypad1:R3
keypad1:R4
keypad1:C1
keypad1:C2
keypad1:C3
keypad1:C4
lcd2:VSS
lcd2:VDD
lcd2:V0
lcd2:RS
lcd2:RW
lcd2:E
lcd2:D0
lcd2:D1
lcd2:D2
lcd2:D3
lcd2:D4
lcd2:D5
lcd2:D6
lcd2:D7
lcd2:A
lcd2:K