/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/faq/how-to-input-a-multiple-digits-number-using-the-keypad
 */

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 4; //four columns

LiquidCrystal_I2C lcd(0x27, 16, 2);

char keys[ROW_NUM][COLUMN_NUM] = {
  {'1','2','3', 'A'},
  {'4','5','6', 'B'},
  {'7','8','9', 'C'},
  {'*','0','#', 'D'}
};

byte pin_rows[ROW_NUM] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

String inputString;
long inputInt;

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Input Value:");
  lcd.setCursor(1,1);
  inputString.reserve(10); // maximum number of digit for a number is 10, change if needed
}

void loop() {
  char key = keypad.getKey();

  if (key) {
    Serial.println(key);
       
    lcd.print(key);

    if (key >= '0' && key <= '9') {     // only act on numeric keys
      inputString += key;               // append new character to input string
    } else if (key == '#') {
      if (inputString.length() > 0) {
        inputInt = inputString.toInt(); // YOU GOT AN INTEGER NUMBER
        inputString = "";               // clear input
        lcd.clear();
        lcd.print("Test Started");

      }
    } else if (key == '*') {
      inputString = "";                 // clear input
      lcd.clear();
      delay(250);
      lcd.setCursor(3,0);
      lcd.print("Test Ended");
      delay(500);
      lcd.clear();
      delay(500);
      lcd.setCursor(3,0);
      lcd.print("Test Ended");
      delay(500);
      lcd.clear();
      delay(500);
     lcd.setCursor(3,0);
      lcd.print("Test Ended");
      
    }
  }
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
keypad:R1
keypad:R2
keypad:R3
keypad:R4
keypad:C1
keypad:C2
keypad:C3
keypad:C4
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL