#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
// Inisialisasi keypad
const byte ROWS = 4; //jumlah baris pada keypad
const byte COLS = 4; //jumlah kolom pada keypad
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {13, 12, 14, 27}; //sesuaikan pinnya sesuai dengan koneksi Anda
byte colPins[COLS] = {26, 25, 33, 32}; //sesuaikan pinnya sesuai dengan koneksi Anda
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
String nilai = "";
double angka = 0.0;
// Inisialisasi LCD
LiquidCrystal_I2C lcd(0x27, 20, 4); // Alamat I2C default untuk LCD 20x4 adalah 0x27
void setup() {
// Inisialisasi LCD
lcd.init();
lcd.backlight();
Serial.begin(115200);
lcd.setCursor(0, 0);
lcd.print("Pilih menu :");
lcd.setCursor(0, 1);
lcd.print("A. Feed Rate");
lcd.setCursor(0, 2);
lcd.print("B. Setpoint Suhu");
}
void menuA(){
}
void loop() {
char Key = keypad.getKey();
if(Key){
if (!(Key == '.' && nilai.indexOf('.') != -1)) { // Cegah duplikasi titik
nilai += Key;
lcd.setCursor(0, 0);
lcd.print(nilai);
if(Key == '#'){
if(nilai.length() > 0){
angka = nilai.toDouble();
nilai = "";
lcd.clear();
lcd.setCursor(0,0);
lcd.print("haloo nilaimu adalah");
lcd.setCursor(8,3);
lcd.print(angka);
}
}
}
}
}
// if (Key >= '0' && Key <= '9'){
// Serial.println(Key);
// myInt = (myInt * 10) + Key -'0';
// digitCount++;
// if (digitCount == 4) {
// Serial.print("You entered: ");
// Serial.println(myInt);
// digitCount = 0;
// myInt = 0;
// }
// }
// if (key=='A') {
// lcd.clear();
// lcd.setCursor(0, 0);
// lcd.print("Tombol ditekan:");
// lcd.setCursor(0, 1);
// lcd.print(key);
// // }