#include <Keypad.h>
#include <LiquidCrystal.h>
const int ROW_NUM = 4; // four rows
const int COLUMN_NUM = 4; // four columns
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] = {10 ,9, 8, 7}; // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {6, 5, 4, 3}; // connect to the column pinouts of the keypad
Keypad customKeypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
const int BUZZER_PIN = 12;
void setup () {
pinMode(BUZZER_PIN, OUTPUT);
}
void loop () {
char customKey = customKeypad.getKey();
if (customKey) {
tone(BUZZER_PIN, 750, 100); // make a beep sound
}
if (customKey) {
if (customKey != NO_KEY) {
//Serial.print(customKey);
Serial.print("Enter your PhoneNo.: ");
class String PhoneString = "";
char PhoneKey = customKeypad.getKey();
if (PhoneKey) {
// Initialize if a key is pressed
Serial.print(PhoneKey);
PhoneString += PhoneKey; // Append the entered digit to the age string
Serial.print(PhoneString);
if (PhoneString.length() == 11) { // If the age string has two digits, categorize the age
Serial.print("Your Phone is: ");
Serial.print(PhoneString);
//delay(1000);
// Convert the age string to an integer
int Phone = PhoneString.toInt();
//lastKeypressTime = 0;
//if (millis() -lastKeypressTime > 10000) {
PhoneString = "";
delay(1000);
// Age3();
}
}
}
}
}