Build your own Rubik’s Cube-solving robot

Last updated Dec 9, 2008 — 30997 views

After buying a Lego Mindstorms robotics kit for his two daughters, Swedish software developer Hans Andersson couldn’t resist using it to create a Rubik’s Cube-solving robot. Complete instructions for replicating the robot, which typically can solve the puzzle within 6 minutes, are available for download.

Andersson’s goal was to construct the robot solely from parts included in a standard Lego Mindstorms NXT kit (shown below). The kits are available for $250 (USD) from Lego’s online store.

Typical Lego Mindstorm NXT project

According to Andersson, the project’s challenges were threefold:

  • A mechanical design using parts from the kit
  • Detecting colors using a simple light sensor
  • Developing an algorithm to efficiently solve the puzzle

“The mechanism looks simple but there’s a lot of work … and many rejected solutions … behind it,” says Andersson. His mechanical design, based on parts available in the Lego NXT kit, appears below. It’s available in an 89-page document (14.6MB PDF file download).

The Tilted Twister solves Rubik’s Cubes in 6 minutes

A traditional Rubik’s Cube has faces comprised of six different colors: white, red, orange, yellow, red, green, and blue. In order to successfully detect the colors of the cube’s faces using a simple light sensor, Andersson found that he needed to modify the colors of some of the faces in the Cube he used.

This brings us to the Rubik’s Cube challenge. As Andersson points out, “a Rubik’s Cube has 43,252,003,274,489,856,000 different possible configurations, [yet] one, and only one, of these possibilities presents the ‘solved’ Cube, having a single color on each of its 6 sides” (as shown above-right).

Aligning all the faces the appropriate way within a reasonable amount of time represented the toughest challenge of all. This task was complicated by the fact that Andersson required the Tilted Twister to accomplish it autonomously using the Mindstorm NXT’s supplied microcontroller module — dubbed the “NXT Intelligent Brick” — rather than with the assistance of an external PC.

The Brick (shown at right) is based on a 32-bit ARM7-based processor (the AT91SAM7S256, utilizing an ARM7TDMI core) and is equipped with 64KB RAM and 256KB flash memory. It’s typically programmed using NXC (“Not eXactly C”), an open-source language similar to C.

Andersson reports that his initial attempts resulted in an algorithm requiring about 100 moves to solve the Cube. After refining his approach, he eventually came up with a more efficient approach that typically solved the cube in “just below 60 faceturns,” which he considers “pretty good, for a general solution.” He wrote and simulated the software on a PC using standard C first, and then ported it to NXC.

Here’s a video demonstrating the Tilted Twister doing its stuff:

Watch the Tilted Twister solve a Rubik’s Cube
(Click image to play video)

For full instructions, parts lists, and links to required components, visit Andersson’s nicely put-together Tilted Twister website.

4 responses to “Build your own Rubik’s Cube-solving robot”

  1. Richard Marks says:

    Cool story and video.

  2. Anonymous says:


  3. acceph says:

    Great!! wow.. amazing, rubiks solved! really solved!

  4. unknown says:

    i have 2.0 could i build it ?