|
|

楼主 |
发表于 2019-7-21 13:06:41
|
显示全部楼层
- /*
- 【Arduino】66种传感器模块系列实验(63)
- 实验六十三:1排4键薄膜开关 Arduino扩展键盘模块(控制面板)
- */
- #include <Keypad.h>
- const byte ROWS = 1; //矩阵键盘行数
- const byte COLS = 4; //矩阵键盘列数
- //按键定义
- char hexaKeys[ROWS][COLS] = {
- {'1','2','3','4'},
- };
- byte rowPins[ROWS] = {6}; //行的针脚连接的接口
- byte colPins[COLS] = {5,4,3,2}; //列的针脚连接的接口
- 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);
- }
- }
复制代码 |
|