Magical 8 Egg



I created the Magical 8 Egg as a playful twist on the classic Magic 8 Ball... something familiar but unexpected. I wanted to take the fun of seeking silly fortunes and package it in a new, lighthearted form that feels even more personal and surprising. It’s a reminder not to take life too seriously! Sometimes you just have to shake things up and see what cracks open :)
It took quite a while to get everything right and almost perfect, but in the end it turned out very nice!
Supplies
Wiring the Speaker to the Adafruit Circut



- Take three wires and cut them down to a reasonable length (not too long and not too short)
- Strip the ends of each wire
- Sauter/Hot glue one end of the wire to the GND hole on the Circuit, and the other end of the wire to the GND hole on the speaker
- Sauter/ Hot glue one end of the wire to the 3.3V hole on the Circuit to the POWER hole on the speaker
- Sauter/ hot glue one end of the wire to the A0 hole on the Circuit to the SIGNAL hole on the speaker
- Turn on the Battery pack and play a tune on your Circuit to make sure the sound comes out from the speaker and not the Adafruit Circuit speakers
- Here is a simple Tune to play if you are struggling!
Setting Up the Inside





- Take the Battery pack and tape it to the bottom of the egg (make sure there are batteries in the pack first!)
- Attach the Adafruit Circuit to the battery pack
- Hot glue the circuit to the battery pack right on top
- Take the wires and fold them so they are more contained, and tape them together
- tape the grouped wires to the wall of the egg
~ (After you decorate the egg) ~
- Melt holes with the hot glue gun at the bottom of the egg lid
- Attach the speaker to where you just melted holes with tape
- Close the lid
Decorating the Egg



- Take the pearls and hot glue them to the lid of the egg to form an "8" or decorate however you like
- Use the white paint and paint the inside of the lid so the wires can't be seen
(Go back to step 2)
The Code (Python)
import time
import random
import math
from adafruit_circuitplayground import cp
SHAKE_ACCEL_THRESHOLD = 15 # Tune this if needed
print("Magic 8-Ball is ready. Shake to get an answer!")
def is_shaken():
x, y, z = cp.acceleration
magnitude = (x**2 + y**2 + z**2) ** 0.5
print(f"Accel magnitude: {magnitude:.2f}")
return magnitude > SHAKE_ACCEL_THRESHOLD
def play_sound(filename):
print(f"Playing sound: {filename}")
cp.play_file(filename)
print("Sound finished.")
# Pulses a color with each answer
def pulse_color(color, duration=3): # 3 seconds
print(f"Pulsing color: {color} for {duration} seconds")
start = time.monotonic()
while time.monotonic() - start < duration:
level = (math.sin(time.monotonic() * 2 * math.pi / 2) + 1) / 2
brightness = int(level * 50)
scaled_color = tuple(int(c * brightness / 255) for c in color)
cp.pixels.fill(scaled_color)
time.sleep(0.05)
cp.pixels.fill((0, 0, 0))
print("Color done.")
while True:
if is_shaken():
print("Shake detected!")
choice = random.choice(["yolk yes", "shell no", "scrambled", "fortune"])
print(f"Random choice: {choice}")
if choice == "yolk yes":
play_sound("yolk yes.wav")
pulse_color((0, 255, 0), duration=5) # Green
elif choice == "shell no":
play_sound("shell no.wav")
pulse_color((255, 0, 0), duration=5) # Red
elif choice == "scrambled":
play_sound("scrambled.wav")
pulse_color((255, 150, 0), duration=5) # Yellow
elif choice == "fortune":
play_sound("fortune.wav")
pulse_color((0, 0, 255), duration=5) # Blue
print("Waiting for next shake...\n")
time.sleep(2) # Prevent immediate retrigger
time.sleep(0.1)