This tutorial is about interfacing to a 4×4 keypad to an Arduino board, save passkey, retrieve passkey and finally unlock something (something like access control). It is an upgrade to the first post I made some months back on Security access control.
- Lithium Battery level indicator with Arduino Uno and LCD
- Control Devices with Arduino and Radio Frequency (RF) communication
- Soil Moisture Level indicator with LED
In this tutorial, our default passkey will not be hardcoded to the code rather it will be saved and retrieved from memory (EEPROM).
EEPROM (also E2PROM) stands for Electrically Erasable Programmable Read-Only Memory and is a type of non-volatile memory used in computers, integrated in microcontrollers for smart cards and remote keyless system, and other electronic devices to store relatively small amounts of data but allowing individual bytes to be erased and reprogrammed.
EEPROMs are organized as arrays of floating-gate transistors. EEPROMs can be programmed and erased in-circuit, by applying special programming signals. Originally, EEPROMs were limited to single byte operations which made them slower, but modern EEPROMs allow multi-byte page operations. It also has a limited life for erasing and reprogramming, now reaching a million operations in modern EEPROMs. In an EEPROM that is frequently reprogrammed while the computer is in use, the life of the EEPROM is an important design consideration.
Let us go ahead and gather our materials. Please note that some of these materials are available in our store:
- Arduino Mega (I had to use these because this tutorials will require many pins and it has a larger memory than the rest).
- 16×2 LCD
- Resistor 100ohms
- Relay module (3.3v or 5volts)
- 4×4 membrane keypad
I used Arduino pins D22, D24, D26, D28 for the rows and pins D23, D25, D27, D29 for the columns.
I used Arduino pins D43 = RS, D41 = EN, D39 = d4, D37 = d5, D35 = d6, D33 = d7
I used Arduino Pin D30 = Relay in pin
How the System works
The system boots up and asks for passkey, when the user enters the correct passkey it will unlock (the relay will switch). if the passkey is incorrect, the attempts will be incremented and if it is up to 3. The lock will freeze, only the correct passkey will unfreezed it. Pressing key A will enter the update passkey mode but this mode won’t work if it is freezed. Pressing key # clears the key and any previous pressed key and pressing the * key will automatically lock the lock again.
Did you enjoy this post? Feel free to drop your comments and follow our Social media channels for tutorials like these.