Parts & wiring

Ever had a hard decision, but didn’t know how to go about deciding? Well, fear not! In this project, you’ll be building a program that will give you a yes or no answer to any question that you ask it.

What you’ll need for this project

To build this project, you will be using the following components:

Brain Board

USB Cable

How to connect the parts

For this project, all you need is the Brain Board, a USB cable and a computer to connect to.

Make sure that you watch the intro video at the top of the page as it’s going to show you how to use the Decision Maker once you’ve uploaded the program.

The final program

Here’s the code we’ll be using to program this invention.
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("  ____/ /__  _____(_)____(_)___  ____     ____ ___  ____ _/ /_____  _____");
  Serial.println(" / __  / _ / ___/ / ___/ / __ / __    / __ `__ / __ `/ //_/ _ / ___/");
  Serial.println("/ /_/ /  __/ /__/ (__  ) / /_/ / / / /  / / / / / / /_/ / ,< / __/ / ");    
Serial.println("__,_/___/___/_/____/_/____/_/ /_/ /_/ /_/ /_/__,_/_/|_|___/_/ ");     delay(1000);     Serial.println();     Serial.println("Ask me a question and I will give you a yes/no answer.");   }     void loop() {       randomSeed(analogRead(0));   // put your main code here, to run repeatedly:
if(Serial.available() > 0) {
    Serial.print(Serial.readString());
    Serial.println();
    delay(1000);
    if(random(0, 2) == 0) {
      Serial.println("I say yes."); // The 'YES' message
    } else {
      Serial.println("I say no."); // The 'NO' message
    }
    Serial.println();
    Serial.println();
    delay(1000);
    Serial.println("Now ask me something else.");
  }
}

I want to change. . .

How the decision messages

Make this more awesome

Learn how to modify the code

Change the decision messages

Giving a simple yes or no answer to all of your questions is a bit boring, don’t you think? At the moment, when a question is being answered, you get a pretty plain response. If the answer is ‘yes’, then it just says: “I say yes.”, and nothing more.

Serial.println("I say yes."); // The 'YES' message

To edit this response, all you need to do is change the text inside the quotation marks. For example, if I wanted to respond with, “The stars tell me that the answer to your question is yes.”, I would need to use the following code:

Serial.println("The stars tell me that the answer to your question is yes."); // The 'YES' message

But that’s only the response when the answer to a question is ‘yes’. We can also edit the response to questions with a ‘no’ answer. The code for this can be found on line 22.

Serial.println("I say no."); // The 'NO' message

Like with our the previous response, all we have to do to change this one is to change the text inside the quotation marks.