Digital Magic Eight Ball

by alecnotalex in Circuits > Arduino

13924 Views, 22 Favorites, 0 Comments

Digital Magic Eight Ball

IMG_0296.JPG
This instructable will show you how to make a customizable digital magic eight ball, with Arduino. It can be customized to say anything you want, and there is no limit to how many phrases it can hold. When shaken, it'll choose one of its phrases randomly and display it on the screen. It can be encased in a magic eight ball shell, but I will not show you how to do that.

The included code has 17 different phrases, but you can easily add your own, or, if you hate mine, delete them.

Here's a video of it in use:

 
DISCLAIMER:
This magic eight ball is not made for high-precision fortune telling. While it is accurate most of the time, I do not recommend using it in any situation where 100 percent accuracy is necessary. I am not responsible for any damages done by inaccurate readings.

Supplies

IMG_0313.JPG
Here's what you need:
1 Arduino
1 16x2 LCD
1 Accelerometer (only tested with the MMA7361)
M M M1 10k Potentiometer
Lots of wire

Assemble

metricclock.png
This is how to assemble it:
1. Look at the picture. Wire up the LCD to the pins specified in the picture, and the potentiometer.
2. Place the accelerometer in the breadboard.
3. Hook up VCC on the accelerometer to 3.3v on the Arduino.
4. Hook up GND on the accelerometer to ground.
5. Hook up Z-OUT on the accelerometer to analog input 0.
6. Hook up SLP to 3.3v on the Arduino.

Code

arduino_logo.jpg
Here is the Arduino code, commented for your convenience:

#include <LiquidCrystal.h> //For LCD
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //Hookup
String phrases[] = /* Known phrases */{"Ask again later", "It is certain", "Without a doubt", "Yes - definitely", "As I see it, yes", "Most likely", "Outlook good", "Yes", "My reply is no", "Very doubtful", "No", "Not a chance", "No way", "Absolutely not", "I doubt it", "Ask again", "I'm uncertain"};
String output;
int numberofphrases = 17; //Number of phrases known, must be the same as, well, the number of phrases known

void setup ()
{
  randomSeed(analogRead(5)); //Seed for random number generation
  lcd.begin(16, 2); //16x2 lcd
}

void loop ()
{
  int z = analogRead(0); //Reading of z axis
  if (z > 870 || z < 490) //Limits- change if you want to, depending on how hard you shake things
  {
    lcd.clear();
    output = phrases[random(numberofphrases)]; //Chooses phrase
    lcd.print(output); //Displays it
  }
  delay(400); //Waits for a bit
}

Downloads

Customizing

Suppose you want yours to say "You don't deserve to know" or "If you pay me, I'll say yes". This step will show you how to add or remove phrases to personalize it.

Go to the line where string phrases[] is defined. This is the list of phrases. To add one, put it in quotes, and separate from the one before it with a comma. Then, add one to int  numberofphrases. It's that simple. To remove a phrase do the opposite. Subtract one from int numberofphrases, and delete the phrase and the comma.

Conclusion

IMG_0296.JPG
You have finished making a digital magic eight ball! Now all that's left to do is to test it. Simply power it on, ask a question, give it a nice firm shake (up and down with the LCD facing up works best), and you will have your answer. Please use this for good, not evil.

If you have any questions, comments, or angry rants, feel free to ask your new magic eight ball post them in the comments section.