In a matrix keyboard there are keys which are arranged in the form of a matrix which consists of several rows and columns. In the figure which is stated below significantly indicates the interfacing process of a matrix keyboard which consists four rows and four columns respectively. We connect a key at the intersection of every rows and columns. Hence there is a total of 4 × 4 = 16 keys in the given matrix. The lines of the columns get connected to Gnd through pull-down resistors.
Even there is a matrix size were to be 8 × 8, for a sum total of 64 keys, only one output port and one input port would be sufficient. The processor sends logic 1 on row 0 by the other row results in exit of logic 0 carried by the instructions
MVI A, 00000001B
Then the processor will start to read the input port. Presently, according to the given Byte pattern, logic 1 is sent out only on row 0. But no key is pressed on this row. As such, the input port receives the value 0000 from the keyboard because of the pull-down resistors as shown in the circuit diagram. The reader might think about the key 9 that is pressed on row 2. But logic 0 is sent out presently on row 2. Hence only logic 0 is received on column 1 via the pressed key. The processor compares the value that is read from the input port with 0000. If both are same, it means that no key is pressed on row 0.
And in this way, all rows will get scanned one after another till the last row to detect the actual key pressed. Thus the keyboard will get interfaced by the 8085 microprocessor.