我試過做盡可能多的研究,因爲我可以在發佈之前,但我是編程新手,所以我的一般無知是在這一點上阻止我從真正能夠知道如何提出正確的問題。Arduino(C/C++)代碼顯示在液晶顯示器上的數組內容
目前的目標:
- 構建陣列,存儲50多個英語單詞/短語;
- 訪問我的Arduino上的數組,並在我的LCD上顯示單個單詞/短語; 和
- 通過單擊Arduino上的按鈕來切換單詞/短語。
硬件規格:SainSmart UnoR3,LCD基於HD44780
問題:寫作時,我按下一個按鈕,將顯示一個新字碼。
代碼爲「你好,世界!」 LCD
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;
}
你能否給我們提供你的代碼和問題? – glautrou
@glautrou我編輯了我的帖子以包含我的代碼和問題(即,當我按下一個按鈕時,代碼會顯示新詞)。 – SocraticDatum