Skip to content

Instantly share code, notes, and snippets.

@lmccart
Last active May 23, 2016 02:39
Show Gist options
  • Save lmccart/9891693942e30c93cf614f52298d88be to your computer and use it in GitHub Desktop.
Save lmccart/9891693942e30c93cf614f52298d88be to your computer and use it in GitHub Desktop.
#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] = {
"shout", "doubt", "disagree", "roll eyes", "empathize", "explain",
"admit", "forgive", "distract", "compromise", "forget", "fortify", "give in", "relate", "confess",
"anticipate", "brag", "care", "challenge", "look up", "surprise", "interrupt", "debate",
"act interested", "talk quietly", "breath in", "shrug", "reconsider", "touch", "open up", "remember",
"criticize", "accept", "frown", "suggest", "accuse", "make a joke", "agree", "respond", "engage",
"ignore", "smile", "stand up", "sit down", "get closer", "cross your arms", "question", "give in", "plan",
"challenge", "think", "downplay", "predict", "move around", "evade", "be kind", "share", "trust",
"pay attention", "change subject"
};
//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