gpt4 book ai didi

arduino - 如何清除 Arduino 中的 LCD?

转载 作者:行者123 更新时间:2023-12-02 01:54:11 25 4
gpt4 key购买 nike

我正在使用串行通信将数据显示到我的 4x20 液晶显示器上。当我填满所有行时,我当然需要清除它。我在网上搜索并找到了类似的东西:

Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command

但它不起作用。我还找到了类似 Serial.println(); 的解决方案但该解决方案(他们称之为作弊)仅适用于串行监视器。那么有没有可能的解决方案来清除显示或从 LCD 中删除单个字符?

最佳答案

你试了吗lcd.clear() ?它在文档 here 中说该命令执行以下操作:

Clears the LCD screen and positions the cursor in the upper-left corner.



显然,您需要 lcd变量(称为 LiquidCrystal 对象)以使用此方法。了解如何创建 here以及下面的基本实现。也许你可以在 lcd.print("hello, world!"); 之后添加一个时间延迟然后添加 lcd.clear(); (就像一个基本的概念验证。)
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup()
{
lcd.begin(16,1);
lcd.print("hello, world!");
}

void loop() {}

查看完整的 LiquidCrystal reference对于它的所有方法和其他示例。

关于arduino - 如何清除 Arduino 中的 LCD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21121659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com