How can I Program Arduino to choose between options?

Hello, whatever you call yourselves. I'm very new to the whole Arduino thing, but I know a bit about the LCD. I'm using Arduino for a project at school, and I've come across a programming question. Like most people I procrastinate, so an answer by Tuesday would be preferred, but I guess I haven't even asked the question yet. How can I Program Arduino to choose between a couple of options? I wanted to create like a "Magic 8 Bot," where when the button is pressed, an LCD gives out a response, like a normal Magic 8 Ball would. I can't figure out how to get the options. The "If" Statement can be easily handled, in fact, it already has, but I just don't know what to do for the options. I've looked into Random Pseudo, and for the answers, I'd look in the serial monitor, and each number given would be an answer (i.e. 1=yes, 2=no, etc.) but it was too difficult for my brain to handle. Any advice towards this matter would be great.

We try to help you with 'your' sketches.

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

Show us a good schematic of your circuit.
Show us a good image of your wiring.

What things have you done using the Arduino so far?

larryd:
We try to help you with 'your' sketches.

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

Show us a good schematic of your circuit.
Show us a good image of your wiring.

What things have you done using the Arduino so far?

I'm assuming that everyone uses the same software, so why can't I just attach a copy of the program file? You could view it and edit it and send it back to me with comments both in the replies and in the comments in the program.

TheRagingTaco:
I'm assuming that everyone uses the same software, so why can't I just attach a copy of the program file? You could view it and edit it and send it back to me with comments both in the replies and in the comments in the program.

Because with attachments it is one extra step.

Either do as you are told to get help, or don't get help. Very simple.

.

TheRagingTaco:
I'm assuming that everyone uses the same software, so why can't I just attach a copy of the program file? You could view it and edit it and send it back to me with comments both in the replies and in the comments in the program.

Because if you can't be bothered to make it easy and convenient for us to see the program you are having problems with then many of us will not be bothered to try to help you.

Good luck sorting out your problems.

Steve

This "how to use the forum" post shows how to post code. Posting code in code tags makes it easy for everyone to see your code.

When were home in front of our computers we have better things to do than help strangers for free. I usually post here while on the bus or waiting in line from my phone, where I can't even view the attachments!

And, even at computer, it's far more work to download a file, make a folder for it, open ide, and then read it. If you want me to do that, I charge 50 bucks an hr :wink:

#include <LiquidCrystal.h>

int button=2

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("I'm Magic 8 Bot!");
  // Setup Pt. 2 of LCD.
  lcd.setCursor(0, 1);
  // Print Bottom part of LCD
  lcd.print("Ask a Question.");

}

void loop() {

  if(digitalRead(button) == HIGH){
    // here, I'd like to have a number of different possible outcomes that can be read out on the lcd, but I can't figure out how to program a randomizer.
  }

}

Here is everything. Also, thank you for these salty comments, they give me a wonderful view of the community. Like I said in the first forum, I'm looking for a way to randomize options. In the code, I made a comment about it in the loop section.

int button=2

Needs more semicolon.

Please at least try to look like the code compiles, before posting it.

Are you aware of the random () function?

UKHeliBob:
Are you aware of the random () function?

I mentioned this in the first post of the forum.

TheRagingTaco:
I mentioned this in the first post of the forum.

And . . .?

How can I Program Arduino to choose between options?

Using switch/case

TheRagingTaco:
I mentioned this in the first post of the forum.

It may be my old eyes (I had my second cataract operation a couple of months ago), but I don't see any mention of the random() function in your first, or any other, post. You do say something about you "looked into Random Pseudo", but I've never heard of that term, and a search for it on the site returns no results.

Computers are very literal. They interpret every letter and symbol exactly as specified, which is why TolpuddleSartre pointed out that you had a missing semicolon (";"), which would prevent your code from compiling. This also means that those who have worked with computers enough to be able to help you tend to become very literal too. And neither computers nor software engineers are telepathic, so are unable to know exactly what you want unless you tell them.

The Arduino IDE included documentation of the random() function seems to tell you exactly what you need to know in order to generate a random long integer in any range required, so if you haven't read that, go and read it, and if you have read it, but find that there's something that you still don't fully understand, come back and tell us what you are having difficulty understanding, and we will try to explain it more clearly.

Or perhaps I haven't understood what a "Magic 8 Ball" is meant to do. Does it give a random selection of a pre-written answer in response to a question?

Assignment's due Tuesday so you're sort of behind the 8-ball?

Have you tried a site search of 'eight ball' ?

I get the feeling that procrastination might begin to end after Monday night TV is over.

If you can dismiss suggestions lightly and rather not dig into them (not ready yet means not ready to do anything yet) then you are procrastinating. If you get bailed out, consider a career in banking....