OLED Magic 8 Ball with Attitude
OLED Magic 8 Ball with Attitude

The Magic 8 Ball toy has first introduced in 1950. It answers yes or no questions via a 20 sided die floating in dark blue fluid - whichever side floats to the top is the "answer." In this project the die and fluid mechanism is replaced with an OLED display and Arduino based microcontroller.

Operation is identical to the original Magic 8 Ball - just flip the ball upside down and then right side up to get your answer (see YouTube video). You can edit or add answers of your choosing, and you're not limited to just 20 answers.

The modified 8 ball outwardly appears nearly identical to the original; there are no external switches, just set the ball down to turn it off and pick it up to turn it on. The ball twists apart to allow LiPo battery recharging or programming to add your own unique answers.

The circuit is very simple consisting of just 4 parts: OLED display, Flora (Arduino based microcontroller board), LiPo battery, and orientation switch. The toughest part of the project is neatly cutting the Magic 8 Ball, so step # 3 provides detailed instructions.

Step 1: Parts and Tools

OLED Magic 8 Ball with Attitude
OLED Magic 8 Ball with Attitude
  • OLED display (Adafruit.com # 938)
  • LiPo battery 3.7 V 1200 mAh, (Adafruit.com # 258)
  • Flora Arduino-compatible microcontroller (Adafruit.com # 659)
  • Aquarium Wired Liquid Water Level Sensor Float Switch; re-purposed as an orientation switch from Amazon.com
  • 5 pin male header (usually you'll have to cut 5 pins from a long single row of header pins, Adafuit.com, Digikey, etc.)
  • 2 pin male header (usually you'll have to cut 2 pins from a long single row of header pins, Adafuit.com, Digikey, etc.)
  • 5 pin female header (usually you'll have to cut 5 pins from a long single row of header pins, Adafuit.com, Digikey, etc.)
  • 2 pin female header (usually you'll have to cut 2 pins from a long single row of header pins, Adafuit.com, Digikey, etc.)
  • 3" PVC pipe 35 mm long
  • 3/4" PVC pipe 25 mm long
  • 3/4" PVC pipe end cap
  • Clear plastic sheet about 2" square (I got from blister packing)
  • Felt or foam sheet stock about 1/16 inch thick (only need 1 sq. inch)
  • Magic 8-Ball, You can purchase a Magic 8 Ball at most toy stores, I got mine at Toys R Us for $12
  • 3M 03614 Scotch-Mount 1/2" x 15' Molding Tape from Amazon.com
  • 26 gage multi-strand colored hookup wire

    Tools

  • Dremel rotary tool
  • Dremel drill press stand
  • Dremel 1.5" dia. Cut-off disk in plastic (see photo) and EZ-Lock mounting mandrel
  • Dremel 9901 Tungsten Carbide Cutter (there are probably better 1/8 dia. cutters for plastic, but this is what I used)
  • Dremel 115 High Speed Cutter
  • Hot Glue gun
  • Soldering iron
  • Wire cutter/stripper pliers
  • Hacksaw
  • Scissors (heavy duty)
  • Black permanent marker

    Step 2: Cut Magic 8 Ball in half and add PVC pipe coupler & float switch mount

    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude

    a) I strongly recommend against trying to freehand cut the 8 ball with a Dremel tool because the plastic is about 1/4 inch think and it's very hard to get a clean cut that way - I am known because I ruined my first 8 ball that way. A better option is to make use of a Dremel drill press setup (see steps 1 -5 in the photos).

    b) After cutting, hot Glue 3/4 and 3 inch PVC pipe sections to bottom half 8 ball. See photos of steps 6 and 7. Notes: The outward appearance depends on performing step 7 with care. Also, see YouTube video below for excellent method to squarely cut PVC pipe.

    How To Cut Pipe Straight / Square With A Hand Saw

    Take a break, the hard part is over.

    Step 3: Prepare PVC end cap, trim down OLED Display mounting ears & modify float switch

    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude

    See photos.

    a) Drill a 5/16 inch hole centered in top of 3/4" PVC end cap - the float switch will later be installed in this hole. Also file two flat areas on opposite sides of the end cap to provide good flat mounting surfaces for LiPo battery and Flora to be installed later

    b) Using the Dremel plastic cut off wheel, trim back OLED mounting ears as shown in the photo - this is needed so it fits properly within the 8 ball view port when we install it later on.

    c) Because the float switch "donut" shuttles back and forth as the 8 Ball is tipped upside down to right side up and vice-versa, it's desirable to reduce the shuttling noise. That's what this modification does. The photo describes the modification..

    Step 4: Wiring connections from Flora to Float Switch & OLED Display

    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude

    a) I recommend beginning this step by first reviewing the wiring pictorial, and photos. There are only 7 connections to make: 2 between the Flora and the float switch and 5 between Flora and OLED display.

    b) The hardest to solder connection is at the Flora on board on/off switch middle inside pin. Begin by adding an extra blob of solder to the pin, then tin with solder the connecting wire, and finally place the tinned wire on top of the switch pin and use the soldering iron to melt the solder together to make the joint.

    c) The float switch wires need to cut down to about 3 inches long, then soldered a 2 pin female connector to the wire ends. Check that the connector can pass freely through the 5/16 hole you drilled in the top of PVC end cap - if not, just file down the connector sides a little bit.

    d) Do Not solder the OLED wire leads to the same side of the board as the display as this will prevent proper mounting to the 8 ball later on - rather solder the leads to the board side opposite the display. Also, because we're using I2C to communicate with the OLED from the Flora, you'll need to solder closed SJ1 and SJ2 pins as marked on the back of the OLED PCB.

    Step 5: Install Inital Software and test

    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude

    a) Setting up and testing the Flora

    For initial setup I suggest only the USB cable be connected to the Flora, disconnect the OLED, float switch and battery

    Because the Flora is not a standard Arduino board like the Arduino UNO, you need to install the "Adafruit special sauce" Arduino IDE programming software which adds Adafruit Flora to the Board options menu (see photo). Also required is installing the Flora device driver. Help with all this is provided by the Adafruit Getting Started with Flora guide, see link below:

    Flora getting started guide

    The Download Software guide section tells you how to download and setup the "Adafruit special sauce" Arduino IDE & Flora device driver

    The Blink onboard LED guide section tells you how to test that everything is working OK.

    b) Setting up and testing OLED Display

    Next, let's get the OLED working. Connect the OLED display to Flora via the 5 pin connectors. You will need two new libraries to make OLED work, see Adafruit guide link below.

    Monochrome OLED breakouts

    The Ardunio Library and Examples guide section tells you how to download and install the 2 new libraries (Adafruit_SSD1306 & Adafruit_GFX).

    With that done, you can test out the OLED display, from the Arduino IDE: File > Examples menu navigate to the example code named "sdd1306_128x64i2c" (see photo to help you get there). Unfortunately the code won't work as is, you'll need to find the line:

    #define OLED_RESET 4

    And change it to:

    #define OLED_RESET 10

    This is necessary because the Flora does not have a digital pin 4 like a standard Arduino UNO, so we're using the Flora digital pin 10. With the OLED display connected to the Flora, and the Flora switched on, you should be able to upload and run the example code. The example code really shows off the OLED's graphical capabilities, none of which I'm currently using with this project - maybe in Gen 2.0!

    If this works Ok, you can now connect the float switch. Since the float is wired in parallel with the Flora onboard switch, the onboard switch needs to be off for the float switch to be active. When the float switch is held upright with the donut resting against the orange o-ring, the switch is on; when the switch is held upside down with the donut resting against the foam washer the switch is off. You may need to press the Flora's reset switch after initially connecting the float switch. You should now be able to turn the OLED example program on and off with the float switch.

    c) Download and install the Entropy Library

    Because the standard Arduino random number function isn't really that random (even when we set the random seed equal to an unconnected analog pin value, for example randomSeed(analogRead(9)). Fortunately, a better random number generator is available, we just need to install the library to enable it. Save the attached file Entropy-v1.0.2.zip on your computer and unzip it to your Arduino/libraries/ directory. You can read more about this random number function at this link.

    Entropy library

    OLED Magic 8 Ball with Attitude
    Entropy-v1.0.2.zip462 KB

    Step 6: Install 8 ball software and full system test

    a) Download the attached file flora8ball.ino to your computer, then open it with Arduino IDE using the File > Open menu option. Save the file to the location on your computer where you keep Ardiuno sketches (program).

    b) Connect to the Flora: USB cable, OLED display and float switch. Assure Flore on-board switch is in the on position, then from the Arduino IDE upload the sketch to the Flora. The OLED should quickly cycle through many possible answers before displaying the final answer. After about 4 seconds it should then display the message: Flip over to try again or turn off.

    c) At this point, hold the float switch in the upright position, turn the onboard switch off & press the Flora reset button. The OLED display should behave as before. You should now be able to turn off the Flora and OLD by turning the float switch upside down. Turning the float switch back to right side up should yield another random answer.

    d) Lastly, connect the LiPo battery to the Flora and then disconnect the USB cable, behavior should remain as above under battery power.

    Acknowledgment: flora8ball.ino incorporates some Adafruit OLED demo code and code from fellow Instructables contributor alecnatalex.

    You're almost done, all that remains is installing the OLED display in the 8 ball and completing the final assembly

    OLED Magic 8 Ball with Attitude
    flora8ball.ino3 KB

    Step 7: Install OLED display in 8 ball

    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude

    a) Cut a thin but stiff piece of clear plastic (I got mine from blister packaging) into a circle sized to fit within the display port of the 8 ball. You can use the cylinder removed from original 8 ball as a guide.

    b) Cut a rectangle from a Post-it note the size of the OLED screen (23mm by 35mm) and place it in the center of the clear plastic piece, see photo. Color in the areas not covered by the Post-it note with a permanent black marker, apply several coats. Then remove the Post-it note.

    c) Place the plastic piece inside the 8 ball and then the OLED display on top of it. Wiggle the OLED around until it aligns with the view window of the plastic piece, then secure in place with hot glue applied at the corners of the OLED, see photos.

    Step 8: Final assembly and test

    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude
    OLED Magic 8 Ball with Attitude

    a) Attached LiPo battery and Flora to the flat sides of the PVC end cap using 3M Molding Tape. Ensure that neither battery not Flora will interfere with the inside walls of the 8 ball. Note: molding tape is commonly used to adhere trim to car bodies, it is somewhat more forgiving than double sided foam tape because it's easily removed and repositioned.

    b) Install the float switch in PVC end cap and secure with the included nut.

    c) Connect all wires - battery, Flora and float switch. Put the PVC end cap electronics control package on the 3/4 PVC post and push gently into place.

    d) Finally, connect the OLED display to the Flora and repeat the full system test from Step 6. If everything is working OK, you can now gently twist the two 8 ball halves together being careful not to pinch any wires.

    That's it - project complete!!!

    .

    Step 9: Maintenance, Customizing Answers & Final Thoughts

    Recharging the LiPo battery. Gently twist and pull the two halves apart to access the battery. You can use a recharging device sometime like this:

    USB LiIon/LiPoly charger

    Customizing Answers. You'll need to modify two sections of the flora8ball.ino code as follows:

    a) You can add more answers (or modify existing) to the phrases array as defined by the code shown below.

    b) As I have the display configured, each answer gets a maximum of 3 lines with 10 characters per line including spaces. You'll need to use spaces to help center the text and control line placement. Answers must be enclosed by double quotes and separated with a comma, example: "I doubt it",

    c) Since the as-is code only uses about 17Kb of 28 available, you have lots of room to add many additional answers.

    char* phrases[] = /* Known phrases */{" When Pigs Fly", "Bet on it dude", " Without a doubt", " Yes definitely", " If hell freezes over", " Most likely", " Outlook good", " Yes", " Nope", " Very doubtful", " No", "No chance in hell", " No way Jose", "Absolutely not", "I doubt it", " Ask again", " I'm uncertain"};

    d) If you add or subtract answers, the array size value needs to be adjusted. For example, if adding 2 more answers, then change

    int numberofphrases = 17; to int numberofphrases = 19;

    e) Once the code is updated, re-upload to Flora using Arduino IDE.

    f) Perhaps someone more clever than I can add Bluetooth capabilities and a smartphone app to customize the answers list.

    Regarding Design choices. Although the Flora were designed for wearable applications, it works well here due to fast boot up performance, built in LiPo JST connector, compact size, and 2A power FET circuit for efficient battery on/off control.

    The float switch was used because I found Tilt ball switches very inconsistent, whereas the float switch was rock solid..


  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel