Basics


The keypad matrix or hex keypad comprising of 16 keys arranged as 4x4 matrix is one of the common interfaces done to a micrcontroller. These are similar to a telephone keypad that we normally come across. In this tutorial we will see about interfacing this keypad to 8051. We will write the code to scan the keys and display the pressed key on the LCD.

Working


For us human beings it takes a few seconds to press a key, but the controller can read the port pin and eventually the keypressed in milliseconds. Hence it is possible to scan a four or more rows and columns while the key is being pressed! In fact, when we will test the code we will realize that a single key press is detected multiple times.

  • KeyBounce: Multiple keypress is also resulted out of mechanical construction of the keys. When we press and release a key, it not just presses once but debounces several times.

There are various ways to eliminate debounce, however we will use time delay to neglect the effect of keybounce.

{{#widget:Iframe

|url=http://xplorelabz.com/wiki/images/c/cc/Keypad_8051.pdf

|width=700

|height=400

|border=5

}}