Sparki tells jokes! I plan to expand this program to add as many jokes as possible. I’d like to get 100 robot jokes collated. I’d also like to integrate this with my free roam code, so that when Sparki is hanging around, you can also read jokes too.
Here is the code:
#include // include the sparki library
void setup() {
sparki.servo(30);
}
void jokechoice(){
randomSeed(analogRead(1));
int joke = random(1, 3);
if (joke == 1){
sparki.clearLCD();
sparki.drawString(10, 3, "Who do bad robots ");
sparki.drawString(10, 5, "run away from?");
sparki.updateLCD();
delay(3000);
sparki.RGB(RGB_BLUE);
sparki.RGB(RGB_GREEN);
sparki.RGB(RGB_RED);
sparki.clearLCD();
sparki.drawString(10, 3, "Robo cop! ");
sparki.updateLCD();
delay(3000);
}
if (joke==2){
sparki.clearLCD();
sparki.drawString(10, 3, "What do you call a ");
sparki.drawString(10, 5, "robot in Antartica?");
sparki.updateLCD();
delay(3000);
sparki.RGB(RGB_BLUE);
sparki.RGB(RGB_GREEN);
sparki.RGB(RGB_RED);
sparki.clearLCD();
sparki.drawString(10, 3, "Cold ");
sparki.updateLCD();
delay(3000);
}
if (joke==3){
sparki.clearLCD();
sparki.drawString(10, 3, "What is a robots ");
sparki.drawString(10, 5, "favourite snack");
sparki.updateLCD();
delay(3000);
sparki.RGB(RGB_BLUE);
sparki.RGB(RGB_GREEN);
sparki.RGB(RGB_RED);
sparki.clearLCD();
sparki.drawString(10, 3, "Micro chips!");
sparki.updateLCD();
delay(3000);
}
}
void loop(){
while(sparki.ping()>10)
{
sparki.RGB(RGB_RED);
sparki.clearLCD();
sparki.drawString(10, 3, "Want a joke? ");
sparki.updateLCD();
delay(3000);
}
jokechoice();
}