This project explores the intersection of robotics, programming, and puzzle solving by automating the solution of a Rubik's Cube. It serves as a hands-on learning experience in mechanical design, sensor integration, and software coordination using LEGO EV3.
An automated system that uses LEGO Mindstorms EV3 hardware and RobotC/Python software to scramble and solve any 3×3 Rubik's Cube configuration. The robot detects cube placement, scrambles the cube, reads cube state, computes a solution via a web-based solver, and executes moves to solve the puzzle, timing the entire process.
- Detects cube presence via ultrasonic sensor before operation.
- Random scrambling using EV3 buttons (Left/Right) and file-based move sequences.
- Cube state acquisition via stored scramble sequence (fallback for color sensor limitations).
- Solving algorithm integration using a Selenium-based web solver for consistent solution times (~1 min).
- Precise manipulation with three motors: gripping arm, rotating base, and color-sensor actuator.
- User interface via EV3 buttons: Left/Right to scramble, Enter to sense/solve, Down to exit.
- Time-to-solve display on EV3 console.
You can find the project demonstration and final report here:
- Place the cube on the base (white on top, green front).
- Press Left/Right button to scramble; robot randomizes cube and writes moves to
scramble.txt
. - Press Enter to sense (via file) and compute solve sequence (
output.txt
). - Press Enter again to execute solve; time taken is displayed.
- Press Down to end the program.
- LEGO Mindstorms EV3 Brick
- 3 EV3 Large Motors (arm flip, base rotation, sensor actuator) — connected to Ports A, B, and C
- EV3 Ultrasonic Sensor — connected to Port 2
- EV3 Color Sensor (optional; fallback implemented) — connected to Port 4
- Standard EV3 buttons for control input
- EV3 structural parts for chassis, arm, and base LEGO Mindstorms EV3 Brick
- RobotC for EV3 (firmware v1.x)
- Python 3.x with Selenium
- ChromeDriver (matching local Chrome version)
- Online Rubik's Cube Solver access
├── main.py # Python script to fetch solution via Selenium
├── runRobot.c # RobotC code controlling EV3 robot
├── readandwritefile.c # EV3 file I/O utilities
├── scramble.txt # Generated scramble move list
├── output.txt # Retrieved solve move list
└── README.md # Project overview and instructions
-
Clone this repository:
git clone https://github.com/s7pan/Rubik-s-Cube-Solver-.git cd Rubik-s-Cube-Solver-
-
Install Python dependencies:
pip install selenium
-
Download ChromeDriver and ensure it's on your PATH.
-
Load
runRobot.c
andreadandwritefile.c
into your EV3 RobotC environment and compile to the brick.
- Power on the EV3 brick and select the uploaded program.
- Ensure the Python environment is running and
main.py
is configured with correct WebDriver path. - Interact via EV3 buttons as described in the Demo section.
- Mechanical redesign of EV3 chassis and gripping arm for stability and precision citeturn0file1
- Modular RobotC functions:
ultrasonic()
,flip()
,base()
,turnLayer()
,readAndTurn()
citeturn0file0 - Python Selenium integration to retrieve solve sequences from online solver citeturn0file1
Test Case | Component | Outcome |
---|---|---|
Ultrasonic check | ultrasonic() |
Pass: Robot waits for cube |
Scramble moves | randomScramble |
Pass: Valid sequences in file |
Solve execution | readAndTurn |
Pass: Cube solved consistently |
Color sensing | colourSensor() |
Fail: fallback used |
- Integrate vision-based color detection for direct cube scanning
- Implement Kociemba's two-phase algorithm on-brick for faster solves
- Add real-time EV3 display of move sequence
- Enhance mechanical grip friction and stability
MIT License
Copyright (c) 2025 s7pan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.