簡體   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