Project showcase
Magic Arduino Ball

Magic Arduino Ball © GPL3+

Another childhood toy. Although the original was brilliant with its icosahedron 20 answers, now with an Arduino I can add as many as I want.

  • 2,176 views
  • 1 comment
  • 6 respects

Components and supplies

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)
to hold the tilt sensor upright

Apps and online services

About this project

Where I got the Idea

I love the Magic 8 Ball and I know that there are some versions rolling out there for the Arduino, but I wanted to make one from scratch. I used the LCD display that came with the Arduino Starter Kit, and a tilt sensor connected to the power supply so the device is turned on only when you pick it and turn it to see an answer, no need for accelerometers and it saves battery. And the code is very simple, a random answer when it starts.

How I did it

For a start I wanted the same answers as the original toy so I used the two raws of the display to write the full answer, in the code I count the characters and split the phrase in the 16th place.

For the ball I used a transparent plastic lamp cover sprayed painted black from the inside, I cut the screw part and left only a lip to hold the circuit. I used a plastic 90 degrees holder glued to the LCD board to attach the Arduino Nano and a little PCB with a 1K potentiometer, the tilt sensor is glued upright to the LCD board (taking care not to damage any component of the LCD board.

Everything is screwed to 2 plywood caps and using the 4 holes in the LCD PCB 4 screw 4 to the plastic ball.

Code

magicArduino ballArduino
#include <LiquidCrystal.h> 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12,11,10,9,8,7,6,5,4,3,2);
String phrases[] = /* Known phrases */{
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes, definitely",
"You may rely on it",
"As I see it,    yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to  yes",
"Reply hazy try  again",
"Ask again later",
"Better not tell you now",
"Cannot predict  now",
"Concentrate and ask again",
"Don't count     on it",
"My reply is no",
"My sources      say no",
"Outlook not so  good",
"Very doubtful",
"no but          I love you"};
String output;
int numberofphrases = 20; //Number of phrases known, must be the same as, well, the number of phrases known
int inPin = 1; 
int val = 0;
      
void setup()
{

  pinMode(inPin, INPUT);    // declare pushbutton as input
  randomSeed(analogRead(5)); //Seed for random number generation
  lcd.begin(16,2);      // set up the LCD's number of columns and rows:
  lcd.clear();
    output = phrases[random(numberofphrases)]; //Chooses phrase
    if(output.length()>16){
     lcd.setCursor(0,0); 
      lcd.print(output.substring(0,16));
      lcd.setCursor(0,2); 
       lcd.print(output.substring(16));
    }
       else{
        lcd.print(output); //Displays it
    }
  
  
}
void loop(){
 
}

Schematics

magicArduino ball
Magicarduinoball

Comments

Similar projects you might like

Magic Cauldron

Project showcase by Ian McKay

  • 5,801 views
  • 3 comments
  • 21 respects

Magic in the Bedroom

Project in progress by Randa El Ali and Jesse Laprad

  • 2,103 views
  • 0 comments
  • 3 respects

Magic 8 Arduino

Project showcase by jsheng

  • 1,213 views
  • 0 comments
  • 3 respects

Magic Projector (A Romantic One)

Project tutorial by Arturo Rosete

  • 1,482 views
  • 1 comment
  • 7 respects

Bright Ball IoT

Project tutorial by Tittiamo

  • 1,380 views
  • 2 comments
  • 4 respects

Arduino Clock with Neopixel Ring Animation

Project tutorial by Alexander

  • 42,066 views
  • 39 comments
  • 64 respects
Add projectSign up / Login