Watch The Video Tutorial 

A keypad is basically a combination of push-buttons in a way to form rows and columns, in this way the number of input/output pins necessary for their connection is reduced. A 4×3 keypad requires 7 input/output pins while a 4×4 will require 8.
The Keypad macro scans the keypad to determine which specific key that has been pressed by output a signal onto the row that the key is on and check if there is a signal on the corresponding column. If there is then the button has been pressed making the connection. This test is repeated for all of the keypad keys allowing for the detection of a pressed key using a single routine.
Flowcode simplifies all this, the Keypad macro contains all the necessary functions for reading the keypad as well as for initializing the port it is connected to.
A combination of a matrix Keypad with an LCD display is usually used as an interface for a user to enter configuration values, password etc.

Figure 1: Typical connection of a matrix Keypad to PIC Microcontroller

—>>To insert an keypad component, on the components tool bar click on Keypad under the Inputs group.
A Keypad (Keypad(0)) will be inserted on the panel.

Figure 2: Inserting a Keypad component

—>> select the Keypad then click on the “….” next to connections properties of the Keypad to open its connection properties.
Here you can set the Port that the Keypad is connected to, and the individual pins for the various connections.

Figure 3: Pin Connections

—>>Click again on the “….” next to the Ext Properties to edit the Keypad properties.

Figure 4: Keypad properties

Here you can choose the keypad type, either a 3×3, 4×3, 4×4 or custom option to define your own rows and columns.


Figure 5: 3×3 Keypad       Figure 6: 4×3 Keypad      Figure 7: 4×4 Keypad

Numeric Values are the numeric values that are returned when the key on the keypad is pressed.
A return value of 255 means that no key has been pressed.
ASCII Values are the ASCII values that are returned when the key on the keypad is pressed.
A return value of 255 means that no key has been pressed.
Component Macros

Drag and drop the Component Macros from the Icons toolbar.

Figure 8: Component Macro

Double click the component macro to open its properties. Click on the Keypad(0) to see its macros.
The Keypad Component provides the following macros:

Figure 9: Keypad Macro

This macro retrieves the number of the key that has been pressed.
The default values are 0-9 for the digits, 10 for * and 11 for #

This macro retrieves the ascii value for the character of the key pressed

Let us create a circuit as shown on the figure 1 above. When the project starts, it display “Matrix Keypad” on the first line of the LCD and “StudentCompanion” on the second line. After a 2s delay, it will display “Press any key…” then you can press any key on the keypad and it will be displayed.

You can download the full project files (Flowcode and Proteus Schematic design) below here.
All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).

Download Keypad Flowcode Project
Download Keypad Proteus Flowcode