我的问题是,当我在串行监视器中输入字符串时,它显示如下:
LCD Arduino误差 setCursor不工作,而且在实际输出之前还有另一个奇怪的字符创建。
这是我的示例代码:
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
lcd.print("hello, world!");
}
void loop() {
String readString;
String Q;
while (Serial.available()) {
delay(1);
if (Serial.available()>0) {
char c = Serial.read();
if(isControl(c)){
break;
}
readString += c;
}
}
Q = readString;
if (Q == "1"){
lcd.setCursor(0,1);
lcd.print("Hello");
}
if (Q == "2"){
lcd.setCursor(0,1);
lcd.print("World");
}
}发布于 2020-04-07 09:12:13
首先,您应该了解LCD的库函数。
若要设置所需的theFirst行,请执行以下操作
lcd.setCursor(0,0); // row index starts with 0如果您只将光标设置回不清除屏幕,可能会有奇怪的字符,sodo a
lcd.clear(); //clears the whole screen或定义空字符串:
String lineClear =" "; // should be 16 spaces for a 16x2 display并作为一个清除序列(例如,对于顶部行)
lcd.setCursor(0,0);
lcd.print(lineClear);
lcd.print("Hello");记住语法是
lcd.setCursor(col, row)
// index for 16x2 is col 0-15,row 0-1
// index for 20x4 is col 0-19,row 0-3 在安装过程中做一个
lcd.clear(); 初始化lcd后,从缓冲区中移除可能的手工艺品。
https://stackoverflow.com/questions/61075974
复制相似问题