The Amazing Annoyatron

0 of 20 lessons complete (0%)

The Wacky Word Wizard

Confuse family members and friends with a host of interesting new phrases and sentences. In this project, you will be creating a program that asks you if you want to know something, and then throws you a completely unexpected answer.


Step 1

Code some chaos

wacky_word_wizard.ino
String word1[] = { "I like ", "I don't like ", "It interests me when ", "I am astonished to ", "Really? You don't like ", "Your teacher hates ", "The Prime Minister secretly enjoys ", "In her spare time, the Queen likes ",
                   "I absolutely hate ", "Do you like ","I know that you like ", "Your principal certainly doesn't like ","The doctor reccomends ","*"};
String word2[] = { "being ", "having ", "saying ", "going ", "getting ", "making ",
                   "knowing ", "telling ", "feeding ", "going to", "*"};
String word3[] = { "school ", "burgers ", "time machines ", "hospital ", "me ", "programming ", "art ", "homework ",
                    "the computer ", "my Arduino ", "insanity ", "screez ","*" };
  
int numberOfWords1=0,numberOfWords2=0,numberOfWords3 =0;

void setup() {
  pinMode(2, INPUT_PULLUP);
  Serial.begin(9600);

  while(word1[numberOfWords1] != "*") numberOfWords1++;
  numberOfWords1--; // to make random number call correct
  while(word1[numberOfWords2] != "*") numberOfWords2++;
  numberOfWords2--;
  while(word1[numberOfWords3] != "*") numberOfWords3++;
  numberOfWords3--;

  Serial.println("Do you want me to tell you something? (Please answer YES)");
}

void loop(){
  if(Serial.available() > 0) {
    if(Serial.readString() == "YES") {
      Serial.println();
      delay(1000);
      Serial.print("Well");
      delay(500);
      for(int i = 0; i < 3; i++) { Serial.print(". "); delay(500); }
      Serial.println();
      Serial.print(word1[random(0,numberOfWords1)]);
      Serial.print(word2[random(0,numberOfWords2)]);
      Serial.print(word3[random(0,numberOfWords3)]);
      Serial.println();
      Serial.println();
      delay(1000);
      Serial.println("Do you want me to tell you something else? (Please answer YES)");
    }
  } else {
    random(0,100);
  }
}