Table of Contents

Crystal Ball

Author: Costan Adriana-Stefania

Introduction

Crystal Ball is a toy which resembles a fortune-telling crystal globe by answering any question with a yes/no kind of answer. The idea started from the “Magical 8 ball” and the fortune-telling slot machines “Zoltan Fortune Teller” used for entertainment at amusement parks or arcades. The Crystal Ball is a toy destined to entertain children. The Crystal Ball toy uses a tilt sensor to replicate the motion of shaking the ball for answers; after asking your question and shaking the “ball”, the LCD will display the answer to your question and the LEDs will start to flicker and you will hear a little song from the piezo, indicating that your question was answered.

General Description

All you need to do to use the Crystal Ball is to ask a yes/no question then to slightly shake the breadboard that contains the display, and you will hear a sound which indicates that your question was answered, this is possible due to the tilt sensor, meanwhile a thematic song is running in the background and the LEDs would flicker during the entire functioning of the toy.

Block diagram:

Hardware Design

Components list:

Electric schematic:

Software Design

For this project I used the library LiquidCrystal_I2C.h such that I can display on the I2C LCD the answers given by the Crystal Ball. In order to make this toy to work I am running the sketches CrystalBall.ino and Music.ino.

In CrystalBall.ino:

Firstly, I have initialized the pins for the tilt sensor, piezo. In setup() I have displayed the initial message on the LCD: “Ask the Crystal Ball!” In loop() I initialized the sequence of the LEDs flickering in order to play constantly during the functioning of the toy and using a switch-case algorithm the toy would generate 1 out of 8 possible answers.

In Music.ino:

First I have defined the notes for the background song, the melody and the notes duration and initialized the pin for the speaker. In loop() I have the for with which I play on repeat the background music.

Obtained results

The initial message:

One of the 8 possible answers:

Conclusions

In conclusion, it was a fun and challenging project that was totally worth it! :)

Download

The code: crystalball.7z

The PDF version of the project: crystal_ball.pdf

Bibliography/Resources

Link for Project Crystal Ball: https://ocw.cs.pub.ro/courses/pm/prj2022/cstan/crystal_ball

Bibliography:

Export to PDF