Arduino Crystal Ball

This is the 11th project in the Arduino Starter Kit. Do note that I have skipped the 9th and 10th projects because my DC motor isn’t working.

Setup

Here’s what we need:

  • Arduino UNO + Breadboard
  • Jumper wires
  • LCD Screen
  • Potentiometer
  • Tilt Sensor
  • 1 x 10 kΩ Resistor
  • 1 x 220 Ω Resistor

Layout

Here’s our schematic, as per the Arduino Projects Book.

And here’s my incredibly messy build:

Code

We will be using the LCD Display (Arduino) library to control our screen. While setting up, all we need to do is print out the initial message we want the user to see.

void setup() {
 lcd.begin(16, 2);
 pinMode(switchPin, INPUT);
 lcd.print("Crystal Ball");
 lcd.setCursor(0, 1);
 lcd.print("At your service");
}

Then, using the random() method, we will give our output.

reply = random(8);
switch(reply) {
    case 0:
    lcd.print("Yes");
    break;
    case 1:
    lcd.print("Probabale");
    break;
    case 2:
    // ...

That’s all there is to it. You can see the full code here.