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:

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.

Step 1: Supplies

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

Step 2: Assemble

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.

Step 3: Code

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
    output = phrases[random(numberofphrases)]; //Chooses phrase
    lcd.print(output); //Displays it
  delay(400); //Waits for a bit

Step 4: 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.

Step 5: Conclusion

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.
<p>hi! could this also work for an MPU-6050 accelerometer?</p>
<p>can you also just put some text on the screen? (without the shaking part?) </p><p>and how do you have to program that?</p>
<p>Nice project!</p><p>Hint: you can find the MMA7361 and other sensors for cheap on this website:</p><p></p><p><a href="http://voltatek.com/en/sensors/82-mma7361-angle-sensor-accelerometer-inclination-module.html" rel="nofollow">http://voltatek.com/en/sensors/82-mma7361-angle-se...</a></p><p>They ship from Canada.</p>
is this battery operated?
I'll answer this one! <br>Nope the Arduino gets power from the Computer threw two of the four USB wires, the other two wires that connect to the computer are for sending packets of Data. <br> <br>Hey Awesome Tut and nice code!
So simple! Thanks!!

About This Instructable




Bio: I am a human being that enjoys to build things. I also say GNU/Linux instead of just Linux. Yeah, I'm that kind of ...
More by alecnotalex:TouchPass: RFID Password Entry TiltKey- Write by Tilting RFI-DJ: MP3 Playing RFID Thing 
Add instructable to: