Microcontroller PIC16F877 Video 44 How To Interface 4x4 Matrix Keypad Using Mikro C For PIC

preview_player
Показать описание
4×4 Matrix Keypad
The 4x4 keypad module consists of 16 keys, these Keys are organized in a matrix of rows and columns. All these switches are connected to each other with a conductive. The 4x4 matrix keypad usually used as input in a project. A matrix keypad is the kind of keypad you see on microwave oven, gas pumps, and calculators.

How the 4×4 Matrix Keypad Works
To detecting a pressed key, the microcontroller grounds all rows by providing 0 to the output pins, and then it reads the columns. If the data read from columns is equal 1111, it means no key has been pressed.
For now let us assume that, the circled key is pressed and see how the key press can be detected by a software routine.
Now the software has to scan the pins connected to columns of the keypad. If it detects a logic 0 in any one of the columns, then a key press was made in that column. This is because the event of the switch press shorts the C2 line with R2. Hence C2 is driven low.

Once the column corresponding to the key pressed is located, the next thing that the software has to do is to start writing logic 1’s to the rows sequentially (one after the other) and check if C2 becomes high. The logic is that if a button in that row was pressed, then the value written to that row will be reflected in the corresponding column (C2) as they are short circuited.
The procedure is followed till C2 goes high when logic high is written to a row. In this case, a logic high to the second row will be reflected in the second column.
We already know that the key press happened at column 2. Now we have detected that the key is in row 2. So, the position of the key in the matrix is (2,2).

Project: How to Interface 4x4 Keypad with microcontroller.

In this project, we will interface the 4x4 keypad with PIC16F877 microcontroller. If we press any key it will show on LCD. The keypad will have interfaced with PORTC of the microcontroller and the LCD will have interfaced with PORTD of the microcontroller.

#microcontroller #clanguage #clanguageprogramming #electronicscreators #microcontroller_lab
Рекомендации по теме
Комментарии
Автор

Would you be able to share the code as a file ?

tristannicholas
visit shbcf.ru