#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "Keypad.h"
byte pinDt = 2; // DOUT
byte pinSck = 4; // SCK
const byte ROWS = 4; //empat rows
const byte COLS = 4; //empat columns
char hexaKeys[ROWS][COLS] =
{ {'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {12,11,10,9}; //hubungkan ke row pinout keypad
byte colPins[COLS] = {8,7,6,5}; //hubungkan ke column pinout keypad
float Clear = 'A'; // tombol A untuk membersihkan input keypad
float Delete = 'B'; // tombol B untuk menghapus angka terakhir input keypad
float Tare = 'C'; // tombol C untuk membersihkan LCD
float Enter = 'D'; // tombol D untuk mengaktifkan motor servo
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS );
LiquidCrystal_I2C lcd(0x27, 20,4); // Set the LCD I2C address for mjkdz I2C module
int Qn = 0;
int lot = 0;
int BKD = 0;
void setup()
{
lcd.begin(20,4);
lcd.init();
lcd.backlight();
lcd.setCursor(5,0);
lcd.print("PROTOTIPE");
lcd.setCursor (5,1);
lcd.print("ALAT UKUR");
lcd.setCursor (7,2);
lcd.print("VOLUME");
lcd.setCursor(0,3);
lcd.print("MINUMAN BERKARBONASI");
delay(3000);
lcd.clear();
}
void loop()
{
{
lcd.setCursor(0, 0);
lcd.print("Masukan Qn : ");
}
{
char key = customKeypad.getKey();
if (key)
{
lcd.setCursor (Qn,1);
lcd.print (key);
lcd.setCursor (0,1);
Qn ++;
if (key == Clear) // Membersihkan LCd
{
lcd.clear();
Qn = 0;
}
if (key == Delete) // Menghapus angka terakhir pada LCD
{
lcd.setCursor(Qn--, 1);
lcd.print(" ");
lcd.setCursor(Qn--, 1);
lcd.print(" ");
}
if (key == Tare) // scale tare ke 0
{
lcd.clear();
Qn = 0;
}
}
}
{
lcd.setCursor(0, 2);
lcd.print("Masukan iot : ");
}
{
char key = customKeypad.getKey();
if (key)
{
lcd.setCursor (lot,3);
lcd.print (key);
lcd.setCursor (0,3);
lot ++;
if (key == Clear) // Membersihkan LCd
{
lcd.clear();
lot = 0;
}
if (key == Delete) // Menghapus angka terakhir pada LCD
{
lcd.setCursor(lot--, 3);
lcd.print(" ");
lcd.setCursor(lot--, 3);
lcd.print(" ");
}
if (key == Tare) // scale tare ke 0
{
lcd.clear();
lot = 0;
}
}
}
}