目的
使用 4 X 4 的矩阵按键输入,再通过串口显示内容
主要函数
#define makeKeymap(x) ((char *)x)
makeKeymap(x)只是将 x 定义为指针形式
Keypad::Keypad(char *userKeymap, byte *row, byte *col, byte numRows, byte numCols)
自定义键映射、针配置和键盘大小
char Keypad::getKey()
返回一个键
使用示例
#include <keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};//
byte rowPins[ROWS] = {19, 18, 26, 17}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {16, 14, 12, 13}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap