Ruben Zilzer
Published © GPL3+

Magic Arduino Ball

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.

BeginnerShowcase (no instructions)8 hours3,966
Magic Arduino Ball

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
4xAA battery holder
4xAA battery holder
bette one the makes a square and
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
1K
×1
tilt sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

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

Story

Read more

Schematics

magicArduino ball

Code

magicArduino ball

Arduino
#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(){
 
}

Credits

Ruben Zilzer

Ruben Zilzer

6 projects • 6 followers
I'm a graphic designer (pre-computers era), a web programmer and digital media teacher support in Sapir College in Israel

Comments