Software Architecture
The Rubik’s Cube Mural Maker uses a distributed software architecture that separates high-level planning and user interaction from low-level motor control. A Raspberry Pi serves as the central coordinator, while multiple Arduino microcontrollers execute time-critical hardware actions.
The Raspberry Pi hosts the web-based user interface, maintains an internal model of the cube state, plans transformation sequences, and manages communication with all connected Arduino boards. The Arduino firmware is responsible only for deterministic motor execution, allowing hardware timing to remain predictable.
This separation of concerns simplifies debugging, improves system reliability during live demonstrations, and enables the system to scale across multiple cubes without introducing additional complexity at the firmware level.
User Interface Walkthrough
The user interface is served locally by the Raspberry Pi and accessed through a standard web browser. The interface enforces a structured workflow in which users select predefined patterns, preview target cube configurations, and explicitly manage undo operations before executing new patterns.
By constraining user interaction to valid state transitions, the interface reduces the likelihood of invalid cube configurations and ensures that physical execution remains consistent with the software model.
Backend Control Logic (Raspberry Pi)
The backend is implemented in Python and runs continuously on the Raspberry Pi. A lightweight HTTP server receives requests from the web interface and translates them into execution actions. This approach avoids the overhead of a full web framework while remaining transparent and easy to debug.
The backend dynamically discovers connected serial devices and broadcasts commands to all detected Arduino boards. Internal state tracking ensures that commands are issued in a valid order and prevents conflicting or overlapping pattern executions.
All execution requests are serialized to ensure that mechanical actions complete before subsequent commands are sent, maintaining alignment and reducing hardware wear.
Pattern Representation and Execution
Each mural pattern is represented as an ordered sequence of cube face rotations defined relative to a known reference configuration. These sequences are generated offline and stored as presets within the backend.
During execution, the Raspberry Pi iterates through the sequence and sends individual motor commands over serial communication. Acknowledgments and time delays are used to ensure that each physical motion completes before the next command is issued.
Undo operations are implemented as explicit inverse sequences rather than implicit reversals, allowing the system to reliably return to known states between pattern executions.
Pattern Search and Planning Algorithm
Pattern generation is performed using a depth-first search (DFS) over the space of legal cube moves. Each node in the search corresponds to a cube configuration, and each edge represents a valid face rotation.
The DFS explores possible sequences of rotations while tracking visited states to avoid redundant paths. When a sequence producing the desired target configuration is found, the search terminates and the resulting move list is stored as a reusable preset.
DFS was selected because pattern generation is performed offline and does not require shortest-path optimality. This approach minimizes memory usage, is straightforward to implement, and produces deterministic sequences that are well-suited for physical execution.
Firmware Design (Arduino)
Two Arduino Uno R4 boards are used to control the eight stepper motors in the system. Each Arduino continuously listens for serial commands from the Raspberry Pi and parses incoming messages into a board identifier, motor identifier, and direction.
If the board identifier does not match the current Arduino, the firmware returns a completion signal without taking action. When a command is addressed to the board, the firmware maps the specified motor, sets the direction pins, and executes the motion using microstepping.
The stepper drivers are configured for 800 microsteps per revolution. A 90-degree cube rotation is implemented by incrementally stepping the motor in small increments with empirically chosen delays to prevent slipping and reduce mechanical stress.
Source Code and Dependencies
The complete software and firmware for this project is available at:
https://github.com/Bugates/PIE-Rubiks-Cube-Mural-Maker
Raspberry Pi Software Dependencies
- Raspberry Pi OS (64-bit)
- Python 3
- pyserial
- qrcode
- Standard Python libraries: socket, json, time, glob, http.server
Arduino Firmware Dependencies
- Arduino IDE
- Arduino core libraries
- Stepper motor driver libraries specific to the hardware used