Rubiks Cube Solver PDF
Rubiks Cube Solver PDF
instructables.com/id/Rubiks-Cube-Solver/
I learned how to solve a Rubiks cube last year, and I was also into Arduino, so eventually I
ended up with an idea to make my own Rubik's cube solver.
1/7
Like many people searching for "Rubik's Cube Solver" on Google, one of the first robots I
found was the Tilted Twister design by Hans Andersson:
I looked around at some other Rubik's cube solvers, but I liked that design because of it's
(relative) simplicity, so I built a similar version of it with popsicle sticks, an Arduino and 2
servos.
In the end, my robot takes about 20 minutes to enter the cube state and solve.
Teacher Notes
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials
Electronics:
- Arduino UNO R3
- wires
- USB cable
You can get all of these parts from any robotics store. I got them from
canadarobotix.com
2/7
Hardware:
- popsicle sticks
- wooden skewers
- thin plywood
- hot glue
Software:
- Pyserial
Step 2: Electronics
Wiring up the servos to the Arduino is pretty straightforward
1. Connect the yellow (signal) wires from the push and rotation servos to pin 6 and 9,
respectively.
2. Connect the positive and negative wires to the 5v power source and ground.
Sometimes the servos had jitters, so I think a few capacitors could have smoothed out
the current.
When I first tried to build the solver, I tried to follow building instructions here:
But I was pretty lazy and didn't follow the instructions, so I made a wooden replica with a
few tweaks.
3/7
I haven't documented every step of the build process, but I think you can reproduce the
tilted twister design with a few tweaks:
Honestly building the physical solver was a lot harder and complex than I expected, so if
you have any questions on how I built the solver, just ask.
So basically the code I wrote uses combinations of pushes, holds and platform rotations
to apply algorithms to the cube.
There are 3 main parts of my code: the algortihm, GUI (enter cube state) and the serial
communications
Let's start with the Arduino sketch. It basically uses algorithms to manipulate the cube
colours:
2. Using a basic layer by layer method of solving the Rubik's cube, I made a function,
cube_decide(), that goes through each stage or the cube solving process.
3. Within each stage, such as cube_decide_cross() (solving the cross), the program would
check for specific locations of colours in the cube, and if an algorithm was matched with
the condition, cube notation like 'U' (Up) or entire algorithms, like fix_cross_instance_1()
would be run.
4. The cube notation and algorithms control the servo functions, such as push_cube() or
rotate_one().
Cube Decide functions < Cube Algorithms < Cube Move functions < Servo functions <
Move Function
4/7
One major breakthrough I had was that I actually simulated the cube's movements in the
program. The program reassigns the values in the arrays to simulate and cube rotation.
This way, the program can simulate the cube move before it physically executes it.
Because I'm new to making Tkinter GUI's (Graphical user interface) and didn't want to
make one from scratch, I found a tic tac toe GUI here:
http://www.dzone.com/snippets/gui-tic-tac-toe-less...
Then I turned the 3x3 array of buttons into something resembling a cube and added a
few buttons. I also added buttons that would change colour each time they were clicked.
Finally I made 5 more windows that would pop up one after the other, and transfer the
colours entered into a local array in the script.
However, I really slapped the code together in a mess, since I simply copy and pasted 6
separate windows, with almost identical functions. Any suggestions on how I could clean
up the code are welcome!
To do that, I used a library called Pyserial, which helps my python script communicate
with the Arduino over a serial interface.
1. After the cube colours were entered in the GUI in Send_Cube_State.py, I converted the
data into a string
2. Used a 'handshake', which in this case the Arduino tells the computer it's ready, then
the computer transfers the data to the robot.
3. The Arduino converts the string received into chars, which are assigned to arrays in
the sketch.
4. Now that the cube colours have been successfully transferred from the computer to
the Arduino, the cube colours can be put through the algorithms and solve the Rubiks
cube.
If you're trying to build the robot yourself, or just trying out the code, here's a checklist to
help you out:
- Pyserial (https://pypi.python.org/pypi/pyserial)
5. Right after uploading, take note of the serial port number at the bottom right corner.
(See picture above)
6. In Send_Cube_State.py, change the address in line 18 to match the number on the IDE.
(See picture above)
6/7
- using the command 'cd', for example:
- cd 'path/to/Cube-Solver'
1. Yellow | Blue
2. White | Green
3. Blue | White
4. Red | White
5. Green | White
6. Orange | White
12. Put the cube inside the solver in the orientation seen here: http://goo.gl/tSqSpp
- In line 32-54, enter the cube colors in the same convention as in step 11.
- Do step 12
Recommendations
7/7