Matrix Keypad Interfacing with Microcontroller

What is a Matrix Keypad?

A keypad is the most widely used devices of digital circuits, microcontrollers or telephone circuits. Many applications require large number of keys connected to a computing system. Provided that it for the most part holds numbers then it can additionally be known as a numeric keypad. In order to use it efficiently, we need a basic understanding of them. A matrix keypad consists of arrangement of switches in matrix format in rows and columns with the microcontroller I/O pins connected to the rows and columns of the matrix such that switches in each row are connected to one pin and switches in each column are connected to another pin. A keypad is generally a matrix arrangement of tact switches which are basically push button switches.

How Matrix Keypad Works?

There are numerous techniques depending on the connection keypad with microcontroller, but the fundamental logic is same the columns are made as input and drive the rows making them as output. So as to detect which key is pressed from the matrix keypad, the row lines are to be made low one by one and read the columns.

Here we are going to see a 4×3 matrix keypad. It is 12 keys keypad consists of four rows and three columns. Assume that if row1 is made low, then read the columns. If any of the key in row1 is pressed then correspondingly the column 1will give low that is if second key is pressed in row1, then column2 will give low. Suppose, if we press one on keypad then D1 and D2 are switched ON makes the connection and displays the number on LCD display through microcontroller. Similarly, all keys will perform same operation as key one. We cannot press two keys at the same time. There should be a time difference between to press the key with one other.

InterfacingInterfacing Matrix Keypad with 8051 Microcontroller

From the circuit, pin 1.0 to pin 1.3 of port 1 of microcontroller are connected to rows of keypad and pin 1.4 to pin 1.6 of port 1 of 8051 microcontroller are connected to columns of keypad.

When the numbers pressed in the matrix keypad load corresponding logical state at the input of the microcontroller i.e., port 1. The program is so written that when say1111 is pressed then microcontroller delivers a logic high command at the controller output. This output high logic from the microcontroller is then fed to the relay driver IC input for ULN2003 output to go low to switch ON the corresponding relay that in turn switches on the load as per the password sent from the keypad. For example if 1111 is pressed the corresponding load 1 is switched ON and while it is pressed again 1111 it switches OFF. Accordingly all other loads are operated as per the passwords.

For example: 1. To switch on the 1st circuit breaker password is “1111”

                        2. To switch off the 1st circuit breaker password is “1111”

                        3. To switch on the 2nd circuit breaker password is “2222”

                        4. To switch off the 2nd circuit breaker password is “2222”

Interfacing circuit
Matrix Keypad Circuit Diagram

An Application involving use of Matrix interfaced to Microcontroller – Programmed Message Sending.

The idea involves using a Microcontroller to send required messages to the given mobile number through GSM communication. The messages are entered using a keypad and effectively stored in the microcontroller.

Fixed number of messages as stored in a microcontroller designated by some numerical numbers. They are recalled, after keying in the receiver’s mobile number so that the very message is sent through the RS232 interfaced cable to the GSM modem. At the time of power on you should get  a display on LCD on first line that “Testing GSM”  and then on the  2nd line the number decrements from “20 to 0” only if modem is powered and the SIM is in place.

Each message is stored in the Microcontroller corresponding to serial number starting from 1 and on pressing the appropriate number through the keypad interfaced to the microcontroller; the corresponding message is send to the entered mobile number through the GSM modem.

Programmed Message Sending Circuit:

The circuit involves the following components:

  • An AT89C52 Microcontroller which is programmed accordingly to send the messages.
  •  A Keypad interfaced to the Microcontroller to enter the mobile number as well as the message number.
  •  A LCD display interfaced to the Microcontroller which displays the necessary instructions as per the program to allow the user to perform the necessary tasks.
  •  A GSM Modem to transmit the messages to the given mobile number.
  •  A RS 232 connector to connect to the GSM Modem.
  •  A Max 232 IC which acts as an intermediate between the microcontroller and the RS 232 connector.
  •  Crystal arrangement to provide appropriate clock input to the Microcontroller.

Programmed Message Sending

On instruction from the LCD display, the mobile number is entered through the keypad and is stored in the appropriate memory location. After that a number between 1 and 9 is entered through the keypad and the Microcontroller accordingly sends the message corresponding to that number. The message is send to the GSM modem through the RS 232 connector and the level shifter IC arrangement which transmits the message to the given mobile number. The whole operation is accordingly displayed on the LCD display.

After some time, the message “ GSM based message sending System” Is displayed and when program button is entered, the display changes to the message-“Enter mobile number” After entering the mobile number # is pressed that prompts to enter the message number. After putting the message number and then # pressed again indicates that “message sending” and then displays “message sent” after sometime and then resumes back to normal display.

If you are not getting any of these message means that SIM card is not getting signal / network not available.

Standard power supply of 12 volt DC and 5 volt through a regulator are made from a step down 12 v transformer along with a bridge rectifier and filter capacitor.

Add Comment