首页 > 解决方案 > 用于设置键盘位置的 const 字节的用途

问题描述

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'} 
};

有人可以解释在 and 中有 byte 和 char 的目的是什么const byte rows=4char keyMap[rows][cols]

标签: c++arduinokeypad

解决方案


它声明了变量的类型。

常量字节列 = 4; 定义一个名为 cols 的常量字节值,值为 4。

char keyMap[rows][cols] = { ... } 用 rows * cols char 值定义一个二维数组。

阅读https://www.arduino.cc/reference/en/language/variables/data-types/char/


推荐阅读