This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)
This is an electronic button controlled Rubik's cube. Keep reading to learn how to build your own!
Step 1: Design and Make the Hardware
The first step in creating an electronic Rubik’s cube is to design the hardware. This can be done through either 3D printing, laser cutting, or many other manufacturing methods. The main criteria for the hardware is that the center tile of each face must have a way to be controlled. I used 6 extensions that were connected to motors using a male/female 90 degree notch. These extensions were then screwed directly into the Rubik’s cube tile. Another design criteria is that there must be a way for the electronics to be connected from the motors to the Arduino, and from the Arduino to the buttons. I did this by designing a spherical type structure so that the servos can be held on six sides while still giving a good view of the cube. This was all done by creating models in solidworks and then 3D printing them.
Step 2: Wire Up the Servo Motors
Once the hardware and support structure is created, the next step is to wire the motors to an Arduino Mega. The servos were placed into the support structure and then all the servo wires were fed to a hole at the bottom of the 3D printed structure. This went into a box where the Arduino was housed. The Arduino supplied 5V and ground to a breadboard power strip and then the power and ground wires of the servos were connected to this strip. The data wires of the servos were then plugged directly into the digital ports of the Arduino.
Step 3: Wire Up the Control Panel
The next step was to create a control panel for the cube.This was done by placing 12 buttons on a large bread board. The Arduino supplied ground to the breadboard and each of the buttons were connected to this power rail. Then the power side of the buttons were wired to digital pins on the Arduino. This circuitry was then placed inside a 3D printed box that labeled each button. I also printed some button extensions. I did this so that the breadboard was hidden and so the buttons were more presentable.
Step 4: Code Setup
Once all the wiring is complete, it is time to write the code. The first part of the code is to include a servo library. Then you have to create six servo objects, each corresponding to an individual servo. Then the pin numbers where the buttons are wired to are defined as corresponding button names. Next you have to create integers for reading the buttons and for the initial positions of the servos. Once all this is done, you have to attach each of the servo objects to the desired digital pin. Then you have to type “Serial.begin(9600)”. The next step is to define all of the used pins as either INPUT or OUTPUT. At this point, you should also write all of the servos to their initial positions and write all of the button pins to HIGH. This concluded the setup of the code.
Step 5: Code Loop
The loop is the part of the code that continuously runs while the Arduino is powered on. The first step of the loop is to read all of the button pins and assign that value to the button integers defined in the previous step. The rest of the code is comprised of if statements. These statements compare all of the button integers to LOW. If this condition is met, the servo is turned a desired amount depending on which button was pressed. The initial position of the servo must then be updated to be equal to the increase made by the button press. The only thing left to do with the code is to put a 200 ms delay on the loop so that the loop doesn’t read a button press more than one time.
Step 6: Enjoy!
This is everything required to create an awesome electronics Rubik’s. Good luck and most importantly, have fun!