Rubiks Bot - Arduino based Cube Solver with Playstore App

Hi everybody,

I wanted to show you my cube solving robot and talk some major issues through which needed to be tackled along the way.

The thread which started it all can be found here:

Rubik's cube Robot solver - Projects Discussion and Showcase / Robotics - Arduino Forum

My thanks are going to Kas for this tremendous amount of work.

Here is the video:

Just another Rubik's Cube solving robot - YouTube

The App Rubiks Bot is for Android and written by myself in Kotlin. It is available in the Playstore.

Actually I did not intend to write this App but I was forced to do it because the original App by Kas, who inspired the whole project stopped working since the Canadian server providing the solution was suddenly offline. So the robot was at that point useless.

Meanwhile Kas references another solution which will work flawless but still requires the solving algorythm on another device. I wanted the solving engine being build into the App itself. The smartphone has more than enough calculation power and the App needed to be written anyway. So with this App there is no other server required to obtain the cube solution.

The App quite explains itself. The BT device must be known by the smartphone beforehand (via settings). The actual connection is than made within the App.

Screencast of Rubiks Bot app

The solving engine relies of course on the work of Herbert Kociemba. When ever I visit his site I’m awe-struck and have a great sense of humility in view of this achievement. To be honest I’m too stupid for solving a cube by myself.

Kociemba's Homepage

The actual Java-Library is called min2phase and can be found on Github. It is an optimized version of the Kociemba-Library. Many thanks to cs0x7f for providing it.

GitHub - cs0x7f/min2phase: Rubik's Cube Solver. An optimized implementation of Kociemba's two-phase algorithm.

This code was compiled into a Java library and included in the Android Kotlin project.


I use the Nano board with the servo breakout board as shown in the picture. This makes connecting the servos very easy. Power are 4 Eneloops which is power enough and the voltage remains within the limit of the board.

Bluetooth module is a HC-06, communication is only one way, so a HC-05 is not required.

Hint: I found the voltage spikes from servo operation can be to much for the HC-06 resulting in a broken BT connection. So just put a well dimensioned capacitor directly to the power terminals of the HC-06 module.

There is not much else required. The servos are plugged directly to the board and for comfortable charging I added a suitable jack.

The whole Arduino code uses 95% of the code from Kas. The major difference is that I use a softserial for the BT module to have the serial port free for debugging purposes. The softserial runs on 9600 Baud to be reliable. There is no speed issue since only a few characters are transmitted.

The Arduino project is attached here.


I use MG996R servos with 180° rotation which can be found quite easy and cheap on ebay in packs of four. They will turn a little more than 180°.

You will have to stretch the pulse width quite beyond the usual 1000-2000µs band. And each servo will require individual numbers.

To get all the numbers for correct position Left, Right and Middle I wrote a little Arduino programm just moving the servos from left to right and to the middle and editing the position constants as long as necessary to get the positions for each servo.


The grippers are also based on the KAS design but with minor changes. I did not like that the plastic parts rotating on the threads of the screws. I use 3mm pins with a smooth surface for this. I also was not comfortable with printing the 25teeth servo socket directly in the part. I preferred to use the delivered servo horn and bolt the gripper to it.

All the parts are printed in PETG. The files can be found here:

Rubiks Bot - A cube solving robot by richimoeller - Thingiverse

Servo gripper for cube solving robot by richimoeller - Thingiverse

The undriven gripper link is a 5 piece design and actually to complicated but I had no better idea.

The driven gear arm uses a Tamiya (RC-Car) special bolt. It is easy to obtain (Tamiya – 50582). But you can use anything else which is suitable.

I glued pieces of anti-slipping-matt to the grippers with double sided adhesive tape. The matt itself ha a checkboard pattern and when you put one piece over the other you can create an almost closed surface. Please see the pictures. The grippers worked right from the beginning and hold the cube really well.

The 2 half cubes do hold the downside and backside rotating servos. The smartphone is looking at the front side of the cube. The yellow base holds all the equipment.

For now this is all I can think of. Good luck if you plan to have a Go yourself. It is a very rewarding project.

i want to make Can you tell me the parts used and where they are connected?

Hello Kang,

I'm not sure what parts and which connection exactly you mean.

You need:

4 MG996R Servos (180°)
Arduino Nano Board
Servo Breakout Board
HC-06 Bluetooth Module
4 eneloop batteries for power

The plastic parts are 3D printed and screwed together with M3 countersunk screws. On the rotating connections 3mm pins are used. You can cut them youreself or by them on ebay. Details are given on the Thingiverse page.

I hope this helps.

It will be easier to give a helpful answer, if the question is a little more specific.

Thanks for your reply

Great Post.. I had been following Kas in his implementation of the rubik solver, and have built the grippers.. I was about to put in on the proverbial shelf because of the issue about external server that had shut, but then found your post. This appears to make a great self contained solution.
I like the base that you produced for it, really quirky. You seem to have a couple of buttons built into the base (or at least holes for them). I can seee there i a couple of holes for the servo wires but was wondering about the others. I guess there is a slider on/off but there also appears to be an allowance for a pushbutton..whats that for?
I can probably work out the connections that you have used from the code but was wondering if you put a wiring diagram together to help. I may not be using a nano as I have some other small boards kicking around. I probably will use an ESP32 board which I think has a built in Bluetooth so I may use that.
I havent inspected the code yet, but you also mentioned about writing some code to allow you to fine tune and set up the grippers. Is that part of the code that you posted or is it separate?

Using the phone and APP is a great way of scanning the cube, enabling me to make reuse of the myriad of phones piling up in my desk. Its a nice clear app to use as well. I also happen to have a samsung A5 that I can use, so will no changes to the mount is needed. In doing the scanning I understand that you manually touch the screen take a snapshop of the appropriate face, and the solver will move to the next face etc... Do you have any thought about taking out the manual touch of the screen, so you can just load up the cube and press go... or is that pushing the colour sensing a bit far. Ohh btw is that a light at the top of phone mount stick... in one picture it just looks like a USB socket..?

Sorry about all the questions, but I was just so glad that someone took up the work that Kas started, especially writing the app which is beyond my skills. Anyway thanks for a great project, I should have mine up and running soon.


Hi Derek,

many thanks for your post. It's nice to see that someone is taking up the matter.

To your questions:

You are right, there is a sliding switch, which powers on the robot. The off-position is wired to allow charging the batteries. For this reason there is also a charging jack build into the base. Of course you can do the charging in a different way. The small push button is wired to the Reset pin of the arduino. I just found it more convinient to have it. I used a small push button soldered to a breadboard and screwed from the bottom. Just see the pics.


The wiring:
I'm not into Fritzing right now and the wiring is also not that complicated.

#define downPinchPin 10 (gripper servo on smartphone side)
#define downRotPin 11 (rotation servo on smartphone side)
#define backPinchPin 8 (gripper servo on other side)
#define backRotPin 9 (rotation servo on other side)

#define myRX 6 (goes to Tx on the HC-06 BT module)
#define myTX 7 (goes via voltage divider to RX on the HC-06 BT module)

Thats it basically. If you use the reset button, than you have to wire it as well.

The servo tuning code:

It's not included yet. Unfortunately I have no access to my project notebook right now, so I will post it later. Just look at examples of the varspeedservo library.

I basically move the servos to the required positions, wait for 3 seconds (for taking measurements) and move them to the other required position and wait again. There are no position changes on the fly. I just edited the numbers in the code and uploaded the code again to the Arduino.

To unlock the > 180° travel required for the rotation servos you have to modify the pulsewidth range as follows:

> void Cube::begin(int speed)  {
>   _downPinch_servo.attach(_downPinch_pin, 1000, 2000);             // modified by richimoeller, values were used during position finding
>   _downRot_servo.attach(_downRot_pin, 520, 2620);                  // default min is 544, max is 2400; modified by richimoeller
>   _backPinch_servo.attach(_backPinch_pin, 1000, 2000);             // modified by richimoeller, values were used during position finding
>   _backRot_servo.attach(_backRot_pin, 520, 2620);                  // default min is 544, max is 2400; modified by richimoeller

So 1ms - 2ms is the normal range. You have to more than double this for the rotation servos.

Color sensing:
You are right, color sensing is a bit in its own. Especially recognizing red from orange is a challenge. The app from KAS was doing it in one go. There were 2 major issues with that:

  1. If the color sensing did sense a wrong color (and it did happen very often if light conditions were less than ideal) than you ended up with an invalid cube string and got no solution for it. You had to do it over and over again until you were lucky because there was no option to correct a wrongly recognized color. My app allows to manually correct the colors if wrongly sensed.

  2. In the app by KAS you had to manually set a delay (in coarse steps, you could not just enter a certain time) until the next shot was taken. So the cube moving needed to be finished until that shot came. The first 3 moves were easy because the cube is just turned by one face. But move 4 and 5 take considerably longer. So I had to choose something like 8s delay to be sure my robot was ready. I powered mine with 4.8V but KAS powered his with 6.6V which makes the servos considerably faster.
    At the end I wanted the App to be usefull for anyone interested regardless of the type of robot. The safest way was to switch manually to the next face when color sensing and correcting is finished.

Yeah, there is a small USB socket on top. The idea was to put an USB light there to enhance color recognition. But my colour sensing is not that bad and you can correct it if it got wrong, so its not needed anymore. The solid-colored cubes are easier sensed but also the sticker cubes do work but are a little bit trickier (more reflection).

I hope this answers your questions so far. As promised I will place here the extra code for position finding of the servos a little later. But it's not rocket science. Just work through the code and the varspeedservo library and you will be able to do it on your own.

Good luck!


Many thanks for your swift response. For me its a really interesting Project. It is also good to hear about the thought processes and identify all the "bits".

No doubt I will tweak things a bit , but that will only be aesthetics.. perhaps add a light or show a timer.. because you and Kas have both done a great job in implementing this and making accessible. Kas very kindly sent me his android app as well, but I haven't loaded it yet. I understand now how he implemented the "click and go" by using timings but i do like your visual check before continuing. I will get back to you and post my own efforts when i eventually get them together.
Best Regards

A quick update on my progress.

The mechanics are now built. Its a hybrid of both the original KAS design and parts of the quirky stand from Richi..

I have access to a laser cutter so the grippers and flat base are cut from Acrylic, with the gripper mounts (shaped like a Rubik Cube) are 3D printed from the excellent STL file from Richi in the link earlier in this Project. Sorry Richi I just used M3 screws rather than pins for the pivots.. :grin: In the Kas original posts it does contain the original DXF drawing for the grippers, which load directly into my lasercutter programme. I didnt have access to a printer large enough to print out the original base so hence the acrylic base, which needs a bit more work.

The grippers work well but now need to be calibrated to not only hold and grip the cube but turn the cube exactly through the +/- 90degrees. So I need to now set up a little programme to get the exact figures to plugs into the main programme relating to the angular movement of the servos.

I am having a bit of a problem with the commands from the phone app, and need to check that I actually getting the clear commands over the bluetooth. I am able to establish a bluetooth connection with the Arduino but the system doesn't seem to respond to requests to move the cube..or start to solve.

Ah well .. still a way to go but looking good.

Hi Derek,

this looks very promising. Thank you for paying me the compliment to use my servo holder.

I was shortly thinking about the BT communciation. I can think of just 2 possibilities why this is not working right now.

  1. You need to make the connection within the app by hitting the red BT symbol. But I think this is to obviuos for not beeing recognized by you.

  2. You need to set the Baud rate of the HC-06 module to the 9600 Baud as declared in the Arduino code, or any other Baud rate you want to use. There are enough tutorials how to do this. Since I'm using soft serial I would not go much faster.

Hopefully it is one of these 2 issues.

Good luck!


Hi Richard
Complement was well deserved.. I used your base as a template and it all screw together perfect, including the self tapping M3 fixing point for the "cube" to the base... and it looks good as well. I just need to put some coloured squares on it... maybe

On The BT.. I didnt miss the need to set up the bluetooth connection and it does confirm the connection is made.. but I never thought about the baud rate though (actually on the HC06 itself). I have been using it for something else and may have set that higher. I need to go back and check it... I am trying to sort out the servo set up at the moment . I havent used servos very much in the past and so is a learning curve for me. I recognise I need to get the movement spot on and trying to take a short cut (or making assupmtions) never works and I am now laboriously going through each of the servos them to make sure they are set up and spot on.

I have got some test files from the KAS post which it good for later on where it goes through the range of grips and turns, so I can check out thoroughly that the base element are working before going back to tackle the bluetooth and smartphone links.

Also a thing like this deserves some blinky light fitted on it!!

Will keep ya informed.


Dear richimoeller,

Thank you for the inspiration to give this a try, but thought I'd give it a go with Meccano:

I have an issue with the bluetooth module cutting out, and see you have a solution by using a capacitor, downside I'm no electronics expert, and therefore would appreciate an insight to what type of capacitor is required and how it is wired into the circuit.

Hi Paul,

nice to see another approach to the robot. I'm looking forward to see it in action.

To your question: I used a low esr electrolyte capacitor connected to VCC and GND of the HC-06 module. 100µF or more will do the trick. You need to put it as close as possible to HC-06 module. These capacitors have a polarity so pay attention to put it the right way.
(I apologize if this remark is to obvious, but I placed it here for peace of mind.)

Good luck!

Kind regards

1 Like

Hi Richard,

Thank you for your time in response to type of capacitor required. I have just finished installation and report that the HC-06 is now working fine. However, i am now faced with another issue, the sequence of rotations appears out of sync as shown in the attached video where I change from the 'front' to 'Right'. All that I have changed in the downloaded files are the servo parameters in Cubemover13 arduino file and the Sieze to 14 in the cube.cpp file.

At this point I was hoping to attch a Zip file of the video, but being a newbie it will not allow me.

So the movement I am getting after capturing the 'Front' face and pressing the 'Right' face is LEFT, CCW then RIGHT, not the just the LEFT turn as expected

Any ideas what is going wrong?
Best regards,

Hi Paul,

so you are almost there. The App is communicating with your robot. Congratulations!

Yes I have an idea what went wrong and it is on my side. Somehow I fetched an outdated cube.cpp file. I will correct that soon but here is the section which should correct it:

//  ----< Scan functions (u, r, f, d, l, b) >-----------------------------
// richimoeller: entered a delay of 500ms here to allow for a clean color recognition shot
void Cube::scanBack()  {
//  grip();
// gripSoft();

void Cube::scanLeft()  {

void Cube::scanFront()  {

void Cube::scanRight()  {

void Cube::scanUp()  {

void Cube::scanDown()  {

void Cube::scanFront2()  {
 // x(3);
 // y(3);

For scanRight() it needs to be y(1) and not x(3). y(1) is also used for the next two moves scanBack() and scanLeft().

I'm sorry for that. I upload the (hopefully) correct cube.cpp file here. I press thumbs that there are no more bugs coming up.

cube.cpp (9.4 KB)

Good luck!


Hi Richard,

Thats done the trick!!! Many thanks for that:

Still work in progress, as I now have to look for an alternative gripper design, as this one is hanging on by the skin of its teeth, doesn't help that there is so much slack in the meccano system.


Hi Paul,

I'm glad it worked! Meanwhile I replaced the Arduino files in my first post.

I have no experience with the Meccano system so I can not help here. Rotating the faces of the cube requires some stiffnes. Kas and me are using a sort of double layer design to achieve this.

You will find a solution, I'm sure.


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.