By Nagabhooshan S.
The key board here we are interfacing is a matrix keyboard. This key board is designed with a particular rows and columns.
These rows and columns are connected to the microcontroller through its ports of the micro controller So only two ports of can be easily connected to the rows and columns of the key board.
When ever a key is pressed, a row and a column gets shorted through that pressed key and all the other keys are left open. When a key is pressed only a bit in the port goes high.
By this high on the bit key in the corresponding column is identified. Once we are sure that one of key in the key board is pressed next our aim is to identify that key. To do this we firstly check for particular row and then we check the corresponding column the key board. To check the row of the pressed key in the keyboard, one of the row is made high by making one of bit in the output port of high.
This is done until the row is found out. Once we get the row next out job is to find out the column of the pressed key. The content of the input port is rotated with carry until the carry bit is set. The contents of the counter is then compared and displayed in the display. The BCD equivalent number of counter is sent through output part of displays the number of pressed key.
The programming algorithm, program and the circuit diagram is as follows. Here program is explained with comments. Keyboard is organized in a matrix of rows and columns as shown in the figure.
The one of the port P1 it understood that P1 means P1. Make all rows of port P0 high so that it gives high signal when key is pressed.
Interfacing Keyboard with 8051 Microcontroller - 8051 Assembly Language Programming
See if any key is pressed by scanning the port P1 by checking all columns for non zero condition. If any key is pressed, to identify which key is pressed make one row high at a time. Initiate a counter to hold the count so that each key is counted. Check port P1 for nonzero condition.
Top Posts & Pages
If any nonzero number is there in [accumulator], start column scanning by following step 9. Otherwise make next row high in port P1. Add a count of 08h to the counter to move to the next row by repeating steps from step 6. If any key pressed is found, the [accumulator] content is rotated right through the carry until carry bit sets, while doing this increment the count in the counter till carry is found.
Interfacing Keypad with 8051 Microcontroller using Keil C
Program to interface matrix keyboard to microcontroller Electronics Directory. About Us. Contact Us.