#include <Keypad.h>
// Define the keypad buttons and pins
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// Define the mobile numbers to be stored
char mobileNumbers[10][11] = {
"1234567890",
"2345678901",
"3456789012",
"4567890123",
"5678901234",
"6789012345",
"7890123456",
"8901234567",
"9012345678",
"0123456789"
};
int found=0;
void setup() {
Serial.begin(9600);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(10, LOW);
}
void loop() {
digitalWrite(12, HIGH);
char inputNumber[11] = "";
int index = 0;
while (index < 10) {
char key = keypad.getKey();
if (key != NO_KEY && key != '*' && key != '#') {
inputNumber[index] = key;
index++;
Serial.print(key);
}
if (key == '#') {
break;
}
}
for (int i = 0; i < 10; i++) {
if (strcmp(mobileNumbers[i], inputNumber) == 0) {
Serial.println("\nMobile number found!");
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
found=1;
digitalWrite(12, LOW);
break;
}
if (i == 9) {
Serial.println("\nMobile number not found!");
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
found=0;
setup();
}
}
delay(500);
}