在发布这篇文章之前,我一直在尽我所能做更多的研究,但是我对编程还很陌生,所以在这一点上,我的普遍无知使我无法真正知道如何问正确的问题。
目前的目标:
硬件规格: SainSmart UnoR3,基于HD44780的液晶显示器
问题:编写一个代码,当我按下一个按钮时,它会显示一个新单词。
代码“你好,世界!”液晶
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
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);
}数组中随机字符串的代码
#include <stdio.h>
#include <stdlib.h>
int main() {
const char *messages[] = {
"Hello!",
"How are you?",
"Good stuff!"
};
const size_t messages_count = sizeof(messages) / sizeof(messages[0]);
char input[64];
while (1) {
scanf("%63s", input);
printf("%s\n", messages[rand() % messages_count]);
}
return 0;
}发布于 2013-08-23 18:07:19
我也有一个Arduino Uno和液晶显示器。您的任务是同时调试硬件和软件。所以,让我问几个问题。
在你的代码清单中,当你运行草图时,你会得到一个“你好世界!”在LCD上显示?
您提供的main()如何与此问题相关。具体来说,main()在哪里运行?我希望这是而不是的一部分,你的素描!!
在您的loop()中,您要做,而不是,有一个延迟。一个刚开始的程序员..。通常情况下,当你想要暂停几秒钟的东西时,你将以每秒数千次的变化来驱动液晶显示器。
因此,添加一个delay(3000);语句来延迟3秒(3,000毫秒),在LCD的更新之间。
接下来,在“循环()”中,您需要测试是否按下按钮,但现在只需显示LCD即可。
请做这件事,并相应地更新你的问题,我会跟进更多的建议/问题。
https://stackoverflow.com/questions/18405684
复制相似问题