Rubik's Cube Solving Machine
Scan, solve and physically turn a scrambled 3×3×3 cube at the push of a button.

- Role
- Course project at HTW Berlin: mechanics, camera controls, solver, motor control and the Buildroot image, each module buildable and testable on its own.
- Motors
- 4 steppers
- OS
- Buildroot Linux
- Stack
- C++, OpenCV, Raspberry Pi 4, Buildroot, GPIO, A4988 stepper drivers, Make, GitLab CI
The machine
Press a button and the machine solves a scrambled cube by itself. The software is three modules, each with its own Makefile and tests: camera controls, the algorithm and hardware controls. A main program ties them together on a Raspberry Pi 4 running a Linux image built with Buildroot.
Architecture
- Camera controls
- Capture each face
- Dominant colour per sticker
- Match colours to centre pieces
- Algorithm
- Cube model6 faces, face turns
- Staged solvercross → F2L → last layer
- Hardware controls
- Move translation
- Stepper controlGPIO → A4988, 90° = 50 steps
Reading colours and finding moves
Colours. For each sticker the pixels are clustered by colour distance and the biggest cluster wins, which copes with uneven light across a sticker. Each sticker is then matched to the nearest centre colour, because the six centre pieces define the six faces.
Moves. Instead of one huge search, the solver follows the layer-by-layer method people use: white cross, first two layers, yellow cross, alignment, then the last layer's edges and corners. Each stage runs a depth-limited search over a short list of moves and move sequences that can't break what the earlier stages solved, so every search stays small.
Hardware
Four stepper motors sit on linear rails around the cube. They slide in to grip a face and turn it in 90° steps. The mechanics went through two builds and two chassis prototypes, all photographed in the repository.
