Rubik's Cube® Solver using an Arduino and MATLAB

Solve Rubik’s Cube® using image processing and Arduino-controlled servo motors
다운로드 수: 2.8K
업데이트 날짜: 2016/9/1

라이선스 보기

In this entry, we build a robot that solves a Rubik’s Cube® using MATLAB, a SparkFun RedBoard (Arduino Uno clone), two servo motors, and a webcam. The submission contains all of the code used to control the robot, a detailed article describing how the robot was built and programmed, and several videos of the final result. Download this submission if you’re interested in learning about our project. Or use it as a starting point for building and controlling your own Rubik’s Cube solving robot.
In addition to hardware components, this project requires MATLAB and Image Processing Toolbox. It also uses MATLAB Support Package for Arduino® Hardware, which can be downloaded for free here:
The initial setup of the project involved building the robot from readily available materials. In addition to the Arduino device, webcam, and servos, we used LEGO bricks, an acrylic sheet, and hard polystyrene foam. The robot was designed with two main parts. A holder holds the cube from below in an open-topped box and can rotate the cube in the horizontal plane. A gripper arm can be lowered over the cube from above to hold two layers still while the holder rotates one face from below. The gripper arm can also be pushed forward to flip the cube to a different side.
With the entire robot assembled and calibrated, solving the cube involves two steps:
1. Read the initial state of the scrambled cube.

MATLAB functions were written to control the servo motors on the Arduino so they could rotate the entire cube in the holder and flip it to a different side. These functions are used to rotate the cube so each of the 6 faces are facing up and capture an image of the face with a webcam. Using Image Processing Toolbox, the color of each facelet is determined. A custom MATLAB UI is used to validate the results and correct any errors.

2. Solve the cube.

The algorithm used for solving the cube is the Thistlethwaite 45 (T45) algorithm. It was used because a MATLAB implementation of the algorithm was already available on the MATLAB Central File Exchange as part of the submission here:

The output of the T45 algorithm determines which faces should be turned. This is then converted to a sequence of moves on the robot that could rotate the cube, flip it to a different side, and turn a single face. Once all the steps are complete, the cube is solved.

인용 양식

MathWorks MATLAB Hardware Team (2024). Rubik's Cube® Solver using an Arduino and MATLAB (, MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2014a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
Help CenterMATLAB Answers에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기
 Power Electronics Control 커뮤니티에 더 많은 파일이 있습니다

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보

Updated license

Added Trademark recognition (®) to first mention of Rubik's Cube® in each section, both in the File Exchange Title/Summary/Description and in the text of the html article which is part of the submission.