Hi, I am trying to help my daughter (4th grade) build a small display for her teacher as a end of the school year gift. Her teacher has several short quotes and favorite words she always uses.
The ideal setup we would like to see will work as follows…
Plug it in, it will randomly display messages (messages DO NOT need to scroll) and automatically change messages after a predetermined time, (maybe 5 - 10sec). I found a sketch and did a little work (and mutilation) to it, I know there is some unnecessary stuff in there. Obviously if you glance at the code you will notice I have very, VERY little experience. Can someone, (or several someone’s) give me some advice, places to look, or answers?
Thanks Bryan
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(switchPin,INPUT);
lcd.print(“Kyndra’s”);
lcd.setCursor(0, 1);
lcd.print(“Message”);
}
void loop() {
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
reply = random(14);
lcd.clear();
lcd.setCursor(0, 0);
switch(reply){
case 0 : lcd.print(“Message 1”); break;
case 1 : lcd.print(“Message 2”); break;
case 2 : lcd.print(“Message 3”); break;
case 3 : lcd.print(“Message 4”); break;
case 4 : lcd.print(“Message 5”); break;
case 5 : lcd.print(“Message 6”); break;
case 6 : lcd.print(“Message 7”); break;
case 7 : lcd.print(“Message 1”);
lcd.setCursor(0, 1);
lcd.print(“xyz”); break;
case 8 : lcd.print(“Message 2”);
lcd.setCursor(0, 1);
lcd.print(“asd”); break;
case 9 : lcd.print(“Message 3”);
lcd.setCursor(0, 1);
lcd.print(“dfd”); break;
case 10 : lcd.print(“Message 4”);
lcd.setCursor(0, 1);
lcd.print(“dfdf”); break;
case 11 : lcd.print(“Message 5”);
lcd.setCursor(0, 1);
lcd.print(“sample”); break;
case 12 : lcd.print(“Message 6”);
lcd.setCursor(0, 1);
lcd.print(“again”); break;
case 13 : lcd.print(“Message 7”);
lcd.setCursor(0, 1);
lcd.print(“keep trying”); break;
}
}
}
prevSwitchState = switchState;
}