Most of the applications of embedded systems require keypads to take the user inputs, especially in case where an application requires more number of keys. With simple architecture and easy interfacing procedure, matrix keypads are replacing normal push-buttons by offering more inputs to the user with the lesser I/O pins. As a Human Machine Interface (HMI) keypad plays a major role in vital microprocessor and microcontroller based projects and equipments. Therefore, this article gives you a brief idea about matrix keypad.
A Matrix keypad is the most commonly used input device in many of the application areas like digital circuits, telephone communications, calculators, ATMs, and so on. A matrix keypad consists of a set of push button or switches which are arranged in a matrix format of rows and columns. These keypads are available in configurations like 3×4 and 4×4 based on the application it is implemented for.
Keypad Internal structure
At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and columns through ports. When a key is pressed, a row and a column make a contact. otherwise, there is no connection between rows and columns. So this is the logic we are going to use.
The status of each keys can be determined by a process called Scanning. There are many methods depending on how you connect your keypad with your controller, but the basic logic is same. For the sake of explanation lets assume that all the column pins (Col1 – Col4) are connected to the inputs pins and all the row pins are connected to the output pins of the microcontroller. In the normal case all the column pins are pulled up (HIGH state) by internal or external pull up resistors. Now we can read the status of each switch through scanning.
- A logic LOW is given to Row1 and others (Row2 – Row-4) HIGH
- Now each Column is scanned. If any switch belongs to 1st row is pressed corresponding column will pulled down (logic LOW) and we can detect the pressed key.
- This process is repeated for all rows.
That’s all guys. I think you could understand the operation of keypad. Here i shows 4×4 matrix keypad. But if you take 3×3 or 4×3 keypad the operation will be same. If you got idea you can try to write a coding. Thank you.