本帖最后由 凯风自北来 于 2015-8-4 18:51 编辑
输入2#之后串口显示是这样的,请问程序哪里出了问题
- #include <Keypad.h>
- char customKey;
- const byte ROWS = 4; //four rows
- const byte COLS = 4; //four columns
- char hexaKeys[ROWS][COLS] = {
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'*','0','#','D'}
- };
- byte rowPins[ROWS] = {9, 8, 7, 6};
- byte colPins[COLS] = {5, 4, 3, 2};
- Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
- void setup() {
- Serial.begin(9600);
- }
- void loop()
- {
- customKey = customKeypad.getKey();
- String res="";
- while( customKey !='#')
- { customKey = customKeypad.getKey();
- res += char(customKey);delay(2);
- }
- Serial.print(res);
- }
复制代码 |