I've tried to do as much researching as I could before posting this, but I am new to programming, so my general ignorance is at this point preventing me from really being able to know how to ask the right questions.
Current goals:
- Building an array that stores 50+ English words/phrases;
- Access the array on my Arduino, and have individual words/phrases display on my LCD; and
- Toggle through words/phrases by clicking a button on the Arduino.
Hardware Specs: SainSmart UnoR3, LCD based on HD44780
Issue: Writing a code that will display a new word when I push a button.
Code for "Hello, world!" 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);
}
Code for random string from an array
#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;
}