Interfacing Keybord With Microcontroller
Keyboard is a basic and essential element of an embedded or microcontroller system. For small and hobby projects a 4×4 (hex) matrix keyboard is sufficient. The keys in the matrix keyboard are arranged in a matrix arrangement in order to utilize the port pins of the microcontrollers efficiently. Here we can interface 16 keys by using just 8 pins of microcontroller. This is shown in the circuit diagram.
As shown in the circuit diagram, the rows are connected to 4 pins of a port, the columns are connected to other four pins, we configure rows as input and columns as output. By grounding one column and setting high all other columns, now by observing the status of the rows, we can come to know which button is pressed. For example, if we ground the first column and if the first row is low, then the first button is pressed. We know that microcontrollers are really fast, therefore they can detect the key press in microseconds, if we hold the switch for long time (for a microcontroller long time is in milliseconds), the microcontroller is triggered more than once, also there is a problem of switch debounce because of the spring action of the switch. To eliminate these problems we should introduce some amount of delay after every key press. The assembly source code for the circuit is given in the table below.
Circuit diagram for interfacing 4×4 keyboard to 8051(89s52):
My prototype for connecting to the main development board:
The assembly program for interfacing 4×4 keyboard:
| ;************************************************* ;Program: Blinking LED. ;Author: Srikanth ;Website: http://shree-electronics.com/ ;Description: Displays the button pressed on the ;keyboard on a 7 segment display. ; ;keyboard format: 0 1 2 3 ; 4 5 6 7 ; 8 9 A B ; C D E F ;************************************************* ;Declarations rw0 equ P2.0; rw1 equ P2.1; rw2 equ P2.2; rw3 equ P2.3; cl0 equ P2.4; cl1 equ P2.5; cl2 equ P2.6; cl3 equ P2.7; ;************************************************* ;Main program org 00h org 30h ;************************************************* row0: mov dptr,#led_data row1: mov dptr,#led_data+4h row2: mov dptr,#led_data+8h row3: mov dptr,#led_data+0ch over: ret ;************************************************* ;************************************************* |













PROJECTS TO GET COSTLY as demand will increase as exams reach so HURRY to GET it on TIME




I WAS NOT UNDERSTAND PROGRAMING WHICH U HAVE WRITE ABOVE PLZ EXPLAIN ME THIS?