#include <LiquidCrystal.h>
//*************** LCD hardware
const int rs = A0, en = A1, d4 = A2, d5 = A3, d6 = A4, d7 = A5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// key pad
#include <Keypad.h>
// Character to hold key input
char customKey;
// Constants for row and column sizes
const byte ROWS = 4;
const byte COLS = 4;
//***************
// Array to represent keys on keypad
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// *************** key board harware Connections to Arduino mega
byte rowPins[ROWS] = {31, 33, 35, 37};
byte colPins[COLS] = {23,25,27,29};
// Create keypad object
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
/* start of LCD set up*/
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// serial monitor set update
// put your setup code here, to run once:
Serial.begin(115200); // to see in serial monitor dont use this Serial.begin if pin 0,1 is used for high or low, in this project it is used
// key pad set up
}
void loop() {
// put your main code here, to run repeatedly:
/*lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Dr Anil Kumar :");
lcd.setCursor(0, 1);
lcd.print("9902037956");
delay(2000);
lcd.clear();
Serial.println(1);*/
customKey = customKeypad.getKey(); // should be looped here else will not wait
if (customKey) {
Serial.println(customKey);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(customKey);
}
}