问题描述
const byte rows = 4; //number of rows on the keypad
const byte cols = 4; //number of columns on the keypad
char keypressed;
char keyMap[rows][cols]={ //keymap defines the key pressed on the keypad according to the rows and columns on the keypad
{'1','2','3','A'},{'4','5','6','B'},{'7','8','9','C'},{'*','0','#','D'}
};
有人可以解释在const byte rows=4
和char keyMap[rows][cols]
中使用字节和字符的目的是什么吗?
解决方法
它声明了变量的类型。
const字节cols = 4;定义一个名为cols的常量字节值,值为4。
char keyMap[rows][cols] = { ... }
定义带有行* cols char值的二维数组。
阅读https://www.arduino.cc/reference/en/language/variables/data-types/char/