#include <Keypad.h>
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] = {19, 18, 5, 17};
byte colPins[COLS] = {16, 4, 0, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
char regNumber[10]; // Assuming a maximum length of 10 characters for the registration number
byte regIndex = 0; // Index to keep track of the registration number input
void setup() {
Serial.begin(115200);
Serial.println("Enter your Reg number using the keypad and press # when done:");
}
void loop() {
char key = keypad.getKey();
if (key) {
if (key == '#') {
// End of registration number input, print the result
Serial.println();
Serial.print("Reg number entered: ");
Serial.println(regNumber);
// You can perform further actions with the registration number here
// Reset for the next input
regIndex = 0;
memset(regNumber, 0, sizeof(regNumber));
} else {
// Append the key to the registration number
if (regIndex < sizeof(regNumber) - 1) {
regNumber[regIndex++] = key;
Serial.print(key);
}
}
}
}