Created
May 23, 2016 03:11
-
-
Save lmccart/7a81f0f37430f886f496dd3f48602087 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 }; | |
static String cues[60] = { | |
"dig", "admit", "compliment", "flirt", "empathize", "look away", | |
"reveal", "chime in", "digress", "confide", "forget", "wink", | |
"notice", "relate", "confess", "joke", "brag", "care", | |
"challenge", "make eye contact", "wonder", "ask", "praise", "pay attention", | |
"suggest", "laugh", "give advice", "contradict", "kiss", "nod", | |
"tease", "criticize", "commiserate", "compare", "wish", "accuse", | |
"wonder", "agree", "offer", "consider", "imagine", "smile", | |
"change topic", "listen", "open up", "disagree", "hold hands", "touch", | |
"plan", "energize", "offer", "elaborate", "predict", "tell a story", | |
"question", "lean forward", "share", "debate", "change the subject", "notice" | |
}; | |
//static String cues[2] = { | |
// "talk it out", "visit the bathroom" | |
//}; | |
char cue_chars[34]; | |
int time = -1; | |
String cue_word = String(34); | |
int cue_interval = 5000; // 1 per second to test | |
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(60)]; | |
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