How to Make a Crystal Ball With Arduino and Substrate
Build a shake-activated Magic-8-Ball style device using Arduino and AI-powered natural language firmware generation with Substrate.
AI-Powered Hardware Coding
Embedded programming is evolving rapidly. Instead of writing long C++ programs or configuring complex toolchains, you can now build hardware using natural language. In this tutorial, we recreate a classic Magic-8-Ball style "Crystal Ball" using an Arduino UNO — and generate the entire firmware and wiring logic using Substrate, our AI-powered hardware coding platform.
With Substrate, you describe what you want, and it automatically produces:
- Wiring instructions - Pin assignments and circuit diagrams
- Fully functional embedded firmware - Ready-to-flash code
- Compilation and flashing steps - No Arduino IDE required
- Validation against wiring mistakes - Catch errors before they happen
- Debugging guidance - Live logs and error diagnostics
This guide walks through exactly how Substrate was used to build a shake-activated device that displays random predictions on a 16×2 LCD.
What We're Building
The Crystal Ball behaves like the classic Magic-8-Ball toy:
- You ask a question
- You shake the device
- A tilt switch detects movement
- A random answer appears on the LCD, such as:
- "Yes"
- "Ask again"
- "Most likely"
- "Doubtful"
The key difference is that all logic and firmware are generated automatically by Substrate.
Components Used
This project is inspired by the Hackster.io Crystal Ball build and uses the following hardware:
Hardware List
- Arduino UNO R3
- Breadboard
- 16×2 LCD display (white on blue)
- Tilt switch (SPST)
- 10kΩ potentiometer (contrast control)
- 220Ω resistor (LCD backlight)
- 10kΩ resistor (pull-up/pull-down depending on configuration)
- Jumper wires
- USB cable for flashing
- Complete Starter Kit (includes all components)
How the Circuit Works
The wiring is straightforward once you understand the purpose of each component. Substrate will generate variant-specific wiring instructions based on your natural language prompt.
LCD (16×2) Wiring
The LCD is configured in four-bit mode to conserve pins. Important connections include:
- RS pin controls command versus data mode
- E pin triggers the LCD to read data
- D4–D7 carry data to the display
- VO pin receives the variable contrast voltage from the potentiometer
- A 220Ω resistor protects the backlight LED
Tilt Switch
The tilt switch acts as a simple digital input that closes the circuit when the device is shaken. Substrate configures the input pin using INPUT_PULLUP or INPUT_PULLDOWN depending on your wiring description.
Potentiometer
Used as a voltage divider to adjust LCD contrast. The middle pin connects to VO.
Using Substrate for Natural-Language Hardware Coding
Instead of writing firmware manually, we used Substrate to generate everything from a single descriptive prompt. An example prompt might be:
"Create a program for Arduino where a tilt switch triggers a random message on a 16×2 LCD."
Substrate responds with:
- Pin assignments
- LCD configuration logic
- Random message selection
- Loop logic
- Initialization code
- Debounce handling
- Flashing instructions
- Wiring validation
This approach eliminates the need for manual coding and accelerates the prototyping process significantly.
Flashing the Board With Substrate
Substrate handles the entire deployment process. Once the firmware is generated:
- It detects the connected board
- Compiles the firmware
- Uploads it over USB
- Verifies successful flashing
- Provides live logs and error diagnostics
This avoids the need for the Arduino IDE or manual compilation, streamlining the workflow from idea to running hardware.
Demonstration
Final Results
When flashed and powered, the Crystal Ball operates exactly like a modernized version of the Magic-8-Ball:
- Tilting the switch triggers the event
- The code selects a random response
- The LCD updates with a readable prediction
- The system resets automatically for the next use
This simple build clearly demonstrates the power of Substrate for embedded development. And also how you can rapidly test multiple designs.
Try Substrate Studio at bedrockdynamics.studio and build your own Crystal Ball — or any hardware project — using natural language.
Questions? Reach us at hello@bedrockdynamics.com
