#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 3;
byte rowPins[KEYPAD_ROWS] = {5, 4, 3, 2};
byte colPins[KEYPAD_COLS] = {A3, A2, A1};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
{'1', '2', '3' },
{'4', '5', '6' },
{'7', '8', '9' },
{'.', '0', '=' }
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);
String current = "";
void showSplashScreen() {
lcd.print("Hello...!!");
lcd.setCursor(3, 1);
String message = "Enter Number";
for (byte i = 0; i < message.length(); i++) {
lcd.print(message[i]);
delay(50);
}
delay(2000);
}
void updateCursor() {
if (millis() / 250 % 2 == 0) {
lcd.cursor();
} else {
lcd.noCursor();
}
}
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
showSplashScreen();
lcd.clear();
lcd.cursor();
lcd.setCursor(1, 0);
}
void processInput(char key) {
if (!(key == '.' && current == "0")) {
current += String(key);
lcd.print(key);
}
}
void loop() {
updateCursor();
char key = keypad.getKey();
if (key != NO_KEY && isDigit(key)) {
processInput(key);
delay(100);
}
}