Home Chipkit Chipkit Magic-8 Ball

Chipkit Magic-8 Ball

by shedboy71

In this example we will create a Magic 8-ball using an Chipkit Uno and an LCD keypad shield, when one of the buttons is pressed a random message will be displayed.

The Magic 8 Ball is a toy used for fortune-telling or seeking advice, developed in the 1950s and manufactured by Mattel. It is often used in fiction, often for humor related to its giving very accurate, very inaccurate, or otherwise statistically improbable answers.

You can read more about the Magic-8 ball at https://en.wikipedia.org/wiki/Magic_8-Ball


Chipkit Uno
LCD keypad Shield (mine was made by SainSmart)


// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
String phrases[] = {"It is certain", "Certainly", "Without a doubt", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "My reply is no", "Very doubtful", "No", "No chance", "No way", "Cannot predictt",
"I doubt it", "Ask again", "Not sure"};
String output;
int numberofphrases = 17;  //match this with the number of phrases
int key  = 0;
void setup() 
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.print("MAGIC 8 BALL");
void loop() 
  lcd.setCursor(0, 0);
  key = analogRead(0); 
  if(key < 1000)
    output = phrases[random(numberofphrases)]; //Chooses phrase


LCD Board Keypad Shield Blue Backlight for Arduino


You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More