In this lesson, you will learn to use Keypad. Keypad can be applied into various kinds of devices, including mobile phone, fax machine, microwave oven and so on. It is commonly used in user input.
In this example, we extend the pins 1~8 of Keypad to connect to the digital pins 2~9.
After uploading the codes to the Mega2560 board, on the serial monitor, you can see the value of the key currently pressed on the Keypad.
By calling the Keypad.h library, you can easily use Keypad.
Keypad(char *userKeymap, byte *row, byte *col, byte numRows, byte numCols)
Initializes the internal keymap to be equal to userKeymap.
userKeymap: The symbols on the buttons of the keypads.
row, col: Pin configuration.
numRows, numCols: Keypad sizes.
Returns the key that is pressed, if any. This function is non-blocking.