大家好,又见面了,我是你们的朋友全栈君。
#include <Keypad.h>
const byte ROWS = 4; //矩阵键盘行数
const byte COLS = 4; //矩阵键盘列数
//按键定义
char hexaKeys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[ROWS] = {9,8,7,6}; //行的针脚连接的接口,第一行连9脚,第二行连8脚
byte colPins[COLS] = {5,4,3,2}; //列的针脚连接的接口,第一列连5脚,第二列连4脚
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey);
}
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/134585.html原文链接:https://javaforall.cn