问题描述
我正在尝试学习 arduino 键盘的使用,以便我可以在未来的项目中使用它。我对键的字符分配有疑问,即使使用教程中的样板代码,我也无法弄清楚。代码如下
// define the symbols on the buttons of the keypad
char keys[4][4] = {
{'1','2','3','A'},{'4','5','6','B'},{'7','8','9','C'},{'*','0','#','D'}
};
byte rowPins[4] = {11,10,9,8}; // connect to the row pinouts of the keypad
byte colPins[4] = {7,6,5,4}; // connect to the column pinouts of the keypad
// initialize an instance of class Keypad
Keypad myKeypad = Keypad( makeKeymap(keys),rowPins,colPins,4,4 );
void setup() {
Serial.begin(9600); // Initialize the serial port and set the baud rate to 9600
}
void loop() {
// Get the character input
char keypressed = myKeypad.getKey();
// If there is a character input,sent it to the serial port
if (keypressed) {
Serial.println(keypressed);
}
}
是的,我所有的别针都正确连接了。这是我得到的损坏输出:
Input output
1 1
2 1
3 3
A 1
4 4
5 4
6 6
B 4
此模式在接下来的两行重复。我不明白这里发生了什么,这让我的大脑崩溃了。请帮忙!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)