Created
March 12, 2014 23:19
-
-
Save brandoaire/9518723 to your computer and use it in GitHub Desktop.
Hacking a Question Block Lamp with the Spark Core
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> | |
LiquidCrystal *lcd; | |
int lcdFunc(String command); | |
int temp = 0; | |
void setup() { | |
// Make sure to update these to match how you've wired your pins. | |
// pinout on LCD ----> [RS, EN, D4, D5, D6, D7]; | |
lcd = new LiquidCrystal(D0, D1, D2, D3, D4, D5); | |
// set up the LCD's number of columns and rows: | |
lcd->begin(16, 2); | |
// Print a message to the LCD. | |
Spark.function("print_lcd", print_lcd); | |
pinMode(A0,OUTPUT); | |
} | |
void loop() { | |
} | |
int print_lcd(String command) { | |
int loc1 = 0; | |
int loc2 = 0; | |
int loc3 = 0; | |
int phrase_num = rand() % 10; | |
int today_count; | |
int total_count; | |
char *phrase_array[] = { | |
(char*)"Good Job, ", | |
(char*)"High Five ", | |
(char*)"Nice Work ", | |
(char*)"Killin It ", | |
(char*)"Go Get Em ", | |
(char*)"You's Bad ", | |
(char*)"Ohhh Yeah ", | |
(char*)"Hot Stuff ", | |
(char*)"Well Done ", | |
(char*)"#WishIWas " | |
}; | |
loc1 = command.indexOf(","); | |
today_count = command.substring(0,loc1).toInt(); | |
loc2 = command.indexOf(",",loc1+1); | |
total_count = command.substring(loc1+1,loc2).toInt(); | |
loc3 = command.indexOf(",",loc2+1); | |
String user_id = command.substring(loc2+1,loc3); | |
String task_name = command.substring(loc3+1); | |
String completed_by; | |
if(user_id=="9100875104063") { | |
completed_by = "Chrlie"; | |
} | |
else if(user_id=="2666439226686") { | |
completed_by = "Zach!!"; | |
} | |
else if(user_id=="6345261643371") { | |
completed_by = "Mohit!"; | |
} | |
else if(user_id=="6635544179518") { | |
completed_by = "David!"; | |
} | |
else if(user_id=="2668254794174") { | |
completed_by = "Steph!"; | |
} | |
else if(user_id=="8054746773773") { | |
completed_by = "Joe!!!"; | |
} | |
else if(user_id=="9100875104071") { | |
completed_by = "Peter!"; | |
} | |
else if (user_id=="2668254794183") { | |
completed_by = "Doc!!!"; | |
} | |
else if (user_id=="9100875104067") { | |
completed_by = "Wilton"; | |
} | |
else if (user_id=="7757227665181") { | |
completed_by = "Shime!"; | |
} | |
else if (user_id=="4756117344275") { | |
completed_by = "Paul!!"; | |
} | |
else if (user_id=="7164312355232") { | |
completed_by = "Ramya!"; | |
} | |
else if (user_id=="6667845238753") { | |
completed_by = "Satish"; | |
} | |
else if (user_id=="2833708705762") { | |
completed_by = "Will!!"; | |
} | |
else { | |
completed_by = "Team!!"; | |
} | |
lcd->clear(); | |
lcd->home(); | |
lcd->print("Tod:"); | |
lcd->print(today_count); | |
lcd->print(" "); | |
lcd->print("Tot:"); | |
lcd->print(total_count); | |
lcd->setCursor(0,1); | |
lcd->print(phrase_array[phrase_num]); | |
lcd->print(completed_by); | |
digitalWrite(A0, LOW); | |
delay(100); | |
digitalWrite(A0, HIGH); | |
delay(100); | |
digitalWrite(A0, LOW); | |
return (1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment