here is the code
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LCD.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);
int kdelay = 50;
int period = 0;
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[COLS][ROWS] =
{
{ '1','4','7','*' },
{ '2','5','8','0' },
{ '3','6','9','#' },
{ 'A','B','C','D' }
};
byte rowPins[ROWS] = { 5, 4, 3, 2 };
byte colPins[COLS] = { 9, 8, 7, 6 };
Keypad kpd = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
int v1 = 0;
unsigned long v2 = 0;
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH);
}
void loop() {
v2 = GetNumber();
Serial.println(v2);
}
int GetNumber()
{
unsigned long num = 0;
char key = kpd.getKey();
while(key != '#')
{
switch (key)
{
case NO_KEY:
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
lcd.print(key);
num = num * 10 + (key - '0');
//Serial.println(num);
break;
case '*':
num = 0;
lcd.clear();
break;
}
key = kpd.getKey();
}
lcd.clear();
return num;
}