LCD与Arduino连接

时间:2013-06-25 13:42:06

标签: arduino lcd

如何使用Arduino在LCD的两行连续显示长文本?

我正在尝试使用Arduino在LCD上显示串行数据,但我输入的句子在第一行LCD后被截断。

1 个答案:

答案 0 :(得分:2)

基本上,要使用最常见的LCD,有a library for Arduino

示例代码是:

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Here is the pinout of your LCD. Read the tutorial to understand what it means.

void setup() {
    // Set up the LCD's number of columns and rows:
    lcd.begin(16, 2);

    // Prints the first line which is 20 characters wide, padded with spaces, and the 'world!' will be on second line.
    lcd.print("hello,              world!");
}

void loop() {
    // Set the cursor to column 0, line 1 (note: line 1 is
    // the second row, since counting begins with 0):
    lcd.setCursor(0, 1);

    // Print the number of seconds since reset:
    lcd.print(millis()/1000);
}

您在液晶显示屏上打印的内容被视为一行。因此,要在两行上打印文本,您需要用空格填充第一行,直到达到该行的字符数。然后,下面的所有文本将显示在第二行。