With the mechanical and electronic parts assembled, we moved on to programming to connect the motors, servos, sensors, and user inputs.
We defined the main behaviors the system needed:
- Homing sequences for all actuators
- Moving and capturing pieces
- Communication with the Nextion touchscreen
- Manual control via the two-button interface
We wrote the program for an ESP32 using the Arduino framework. Since networking code ran in the background, all motion routines had to be completely non-blocking.
We used multiple state machines to control the cart, gripper, capture system, board rotation, manual controller, and screen.
We started with a simple test program for the controller. Using the two buttons, we sent signals to the actuators to confirm the mechanical and electrical systems worked


After that, we wrote a second program to control the actuators via serial commands from a computer. We used this to figure out the right angles and positions for each motor to reach every square on the board and the capture slots.


We used the Nextion Editor to build the touchscreen interface. It allowed us to:
- Trigger homing
- View system status
- Manually control the system
Here are some screenshots:



The final motion control codebase was over 2000 lines long. It included:
- 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.