With the mechanical and electronic parts assembled, it was time to tackle the brain of the system—the programming. This is where everything comes together: motors, servos, sensors, and user interactions.
We started by defining the main behaviors the system needed to perform:
-
Homing sequences for all actuators
-
Normal and capture piece movements
-
Communication with the Nextion touchscreen
-
Manual control using the physical controller (two-button interface)
The whole program was written for an ESP32 board using the Arduino framework. Because we had networking code running in the background, it was essential that all motion routines were fully non-blocking.
We structured the code around multiple state machines to control:
-
The cart
-
The gripper system
-
The capture system
-
The chessboard rotation
-
The manual control interface
-
The Nextion screen
We started by writing a simple program to test the controller. Using the two-button interface, we verified that we could successfully send signals to the actuators and confirm that everything was functioning correctly—both electrically and mechanically.


Once that was confirmed, we developed a second program that allowed us to control all actuators via serial commands from the computer. This program was crucial: it helped us identify and fine-tune the exact positions and angles each motor needed to reach every square on the chessboard and each slot in the capture zone.


Using the Nextion Editor, we built the graphical interface displayed on the touchscreen. The interface allowed us to:
-
Trigger homing procedures
-
Display system status
-
Manual control
Here are some screenshots of the custom interfaces we made:



By the end of development, the full codebase for the motion control system totaled over 2000 lines of code. It includes:
- Multi-layer state machines
- Non-blocking motion sequences
- Safety logic for movement constraints
Nasser
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.