繁体   English   中英

LCD上显示特殊字符而不是数字 - Arduino

[英]Special characters are displaying on LCD Instead of numbers - Arduino

我想将从 4x3 矩阵键盘按下的数字打印到我的 20x4 液晶显示器上,但结果却出现了 aw 和箭头。 错误看起来像这样。 这是我的代码。

#include <LiquidCrystal.h>
#include <Keypad.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//RS,EN,D4,D5,D6,D7

const byte Rows= 4; //number of rows on the keypad i.e. 4
const byte Cols= 3; //number of columns on the keypad i,e, 3

//we will definne the key map as on the key pad:

char keymap[Rows][Cols]={
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rPins[Rows]= {9, 8, 7, 6}; //Rows 0 to 3
byte cPins[Cols]= {5, 4, 3}; //Columns 0 to 2

Keypad kpd= Keypad(makeKeymap(keymap), rPins, cPins, Rows, Cols);

void setup() {
  lcd.begin(20, 4);//initializing LCD
}

void loop() {
  char keypressed = kpd.getKey();
  if (keypressed != NO_KEY) {
    lcd.print(keypressed);
  }
}

请帮帮我。

您的两个模块共享一些相同的引脚,这是问题的根源:

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//RS,EN,D4,D5,D6,D7
byte cPins[Cols]= {5, 4, 3}; //Columns 0 to 2

从这些声明中,引脚 5、4 和 3 似乎是共享的。 当外围设备之间共享引脚时,会发生各种奇怪的事情。 然后,当您说每个设备似乎单独运行良好,而没有其他设备时……好吧,我会说重叠的引脚是您的罪魁祸首。

看看是否有办法重新映射一个或其他设备,以免共享引脚。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM