c++ - 用于设置键盘位置的 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=4
吗char keyMap[rows][cols]
?
解决方案
它声明了变量的类型。
常量字节列 = 4; 定义一个名为 cols 的常量字节值,值为 4。
char keyMap[rows][cols] = { ... }
用 rows * cols char 值定义一个二维数组。
阅读https://www.arduino.cc/reference/en/language/variables/data-types/char/
推荐阅读
- php - 在简单的调查应用程序中链接问题的答案
- java - Vbox 中的 fillWidth 属性不起作用
- amazon-web-services - 如何从 AWS Lambda Python 中调用 Simple Systems Manager 'RUN COMMAND'
- for-loop - EJS + htmlWebpackPlugin + ejs-compiled-loader。无法使用循环制作导航列表,获取 TypeErrors
- r - ggplot2 geom_text 在水平分组条形图上定位文本
- php - 如何摆脱 Wordpress 中的错误“max_user_connections”活动连接?
- groovy - 在迭代期间更改所有列表项
- html - 如何将离子图标放置在离子 HTML 移动 UI 的文本字段中?
- google-analytics - Firefox 版本 >56 我可以实时查看流量,但不能在任何报告或仪表板中查看
- ios - 将 CADisplayLink 与 tableViewCells 一起使用所需的指导