Created
May 28, 2016 16:55
-
-
Save lmccart/442445dbf4a0d7cbf04e7403d54a8ebb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd1(12, 11, 16, 17, 18, 19); | |
LiquidCrystal lcd2(12, 5, 6, 7, 8, 9); | |
LiquidCrystal lcds[2] = { lcd1, lcd2 }; | |
int leds[2] = { 2, 10 }; | |
// wedding | |
static String cues[48] = { | |
"have kids", "doubt", "radically love", "actively love", "dont give up", "be honest", | |
"assume good", "walk away", "share", "listen", "hug 10 secs", "be happy", | |
"be kind", "use silence", "find joy", "employ humor", "be as christ", "respect", | |
"appreciate", "talk it out", "pray", "tell the truth", "set expectations", "play fight", | |
"make them laugh", "be patient", "share a vision", "visit the bathroom", "have sex", "don’t be mean", | |
"choose to love", "make mouth sounds", "comment", "dance", "be unpredictable", "make plans", | |
"stay open", "change it up", "get on with it", "speak your mind", "let it go", "hold on", | |
"take a risk", "keep communicating", "be creative", "make space", "remember", "answer" | |
}; | |
char cue_chars[34]; | |
int time = -1; | |
String cue_word = String(34); | |
int cue_interval = 3000; | |
boolean cur_user = 0; | |
int e; | |
String werd = String(34); | |
String remix = String(34); | |
boolean break_line = false; | |
void setup() { | |
//LED - Backlight | |
pinMode(leds[0], OUTPUT); | |
pinMode(leds[1], OUTPUT); | |
// set up the LCD's number of columns and rows: | |
lcds[0].begin(16, 2); | |
lcds[1].begin(16, 2); | |
} | |
void loop() { | |
if (time == -1 || time >= cue_interval) { | |
time = 0; | |
pickCue(); | |
handleCueOut(); | |
} | |
time++; | |
delay(10); | |
} | |
void pickCue() { | |
cur_user = !cur_user; | |
cue_word = cues[random(48)]; | |
break_line = cue_word.indexOf(" ") != -1 && cue_word.length() > 16 ? true : false; | |
} | |
void handleCueOut() { | |
// turn off both screens - Backlight | |
for (int i = 0; i < 2; i++) { | |
lcds[i].noDisplay(); | |
digitalWrite(leds[i], LOW); | |
} | |
// prepare cue for display | |
remixCue(cue_word, break_line, true).toCharArray(cue_chars, sizeof(cue_chars)); | |
// display cue | |
lcds[cur_user].clear(); | |
delay(5); | |
lcds[cur_user].print(cue_chars); | |
delay(5); | |
if (break_line) { | |
remixCue(cue_word, true, false).toCharArray(cue_chars, sizeof(cue_chars)); | |
lcds[cur_user].setCursor(0, 1); | |
lcds[cur_user].print(cue_chars); | |
delay(5); | |
} | |
digitalWrite(leds[cur_user], HIGH); | |
lcds[cur_user].display(); | |
} | |
// This function adds padding to properly print cues that need to break over two lines. | |
// This might need to change based on size and spec of screens used. | |
String remixCue(String c, boolean db, boolean first) { | |
werd = ""; | |
remix = ""; | |
if (!db) | |
werd = c; | |
else if (db && first) | |
werd = c.substring(0, c.indexOf(" ")); | |
else | |
werd = c.substring(c.indexOf(" ") + 1, c.length()); | |
if (werd.length() % 2 == 1) | |
e = 1 + (15 - werd.length()) / 2; | |
else | |
e = (16 - werd.length()) / 2; | |
for (int i = 0; i < e; i++) | |
remix.concat(" "); | |
remix.concat(werd); | |
remix.toUpperCase(); | |
return remix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment