Introduction: Homemade Chess Robot

In this Instructable, I show you how to build a chess robot! The chess robot was designed in 3 parts: the mechanical design, the electrical circuitry, and the Python/Arduino code. Each step can be completed individually and in any order you choose!

The chess robot works by having a human player make a move, which the reed switch sensors detect and send the move to the python code. The python code chooses a computer move and sends it to Arduino to execute the move with the robotic arm.

Homemade Chess Robot Showcase:

How to Build a Chess Robot:

Step 1: Obtain Materials

There are quite a few materials required to complete this project. Everything I used to complete this project including the links to where I obtain all the materials (affiliate links) can be found in my ChessRobotMaterialsList.pdf file. The mechanical materials and electrical materials can be obtained at different times. Once you have the required materials for either the mechanical or electrical section, it is time to begin building!

Step 2: Mechanical - Constructing the Channels

The 3 PVC plastic tracks (x, y, and z) provide a channel for the blocks to slide within to move the robotic arm. Construct the x-track according to the drawing PDF. The exact placement of the 1/8 diameter tap screws is not very important as long as the screws don't collide. After you have constructed the x-track, construct the Y and Z tracks in a similar way according to the respective drawing PDF files. It may be helpful to cut the X, Y, and Z blocks first so that you can ensure there is enough room for the blocks to slide through their respective channel.

The downloadable PDF files below contain the drawings and dimensions for the x, y, and z track. Follow the drawing files precisely to construct the robot.

Step 3: Mechanical - Securing the Lead Screws and Stepper Motors

The lead screws (1/2 - 10" Acme Threaded Rod) for each track is lathed down slightly on one side to 5 mm in order to fit inside the motor coupler. The other end of the coupler is secured to a stepper motor. This allows the lead screw to turn when the stepper motor turns. Ball bearings at the end of the X and Y track help support the lead screw while allowing it to rotate smoothly.

The X and Y Nema 23 stepper motors are secured to the tracks with the stepper motor holders from the materials list. The Z Nema 17 stepper motor is secured to its track with the z-track-lock PVC plastic piece.

Step 4: Mechanical - Building the Gripper

Building the gripper requires a 3D printer, a Trossen ASM-RGS-13 Servo Motor from the materials list, M2.5, and M3 screws. The STL files to print the gripper can be downloaded below, the gripper is constructed according to the explosion view in the image above. The gripper attaches to the Z block using M3 screws.

Step 5: Electrical - Circuit Overview

The Arduino combined with the MUX Shield and the 2 MCP23017 Chips has a total of 93 pins to use on this project. The overview of the circuit can be found in the image above or in the Fritzing diagram that you can download below.

List of components that use Arduino pins in this project:

64x Reed Switches

3x Stepper Motor Drivers (2 pins each)

1x Servo Motor

3x Limit Switches

3x Push Buttons

Step 6: Electrical - Connecting the Reed Switches

Copper wire from the materials list is ran along with sides of each column of the chessboard to provide an easy ground connection for the reed switches. The reed switches are glued to the bottom of each square of the chessboard with one side of the reed switch soldered to the grounding wire and the other side of the reed switch soldered to a ribbon cable connected to an Arduino pin. The glue does not make contact with the glass casing of the reed switch, only the wire part of the reed switch to avoid any heat issues with the switch.

Step 7: Electrical - Connecting the Stepper Motor Drivers

The stepper motors are wired directly to the ST-6600 stepper motor drivers using the A+, A-, B+, B- connections on the drivers. The documentation for the stepper motors will indicate exactly which colored wire goes where. The PIL+, and DIR+ connections are each wired to an Arduino pin. The PUL- and DIR- are wired to Arduino's ground. The DC+ connection is wired to the 24V power supply and the DC- connection is wired to the power supply's ground.

The gripper servo motor does not require a motor driver, it is connected directly to an Arduino pin.

Step 8: Electrical - Push Buttons and Limit Switches

The push buttons and limit switches are each connected to an Arduino pin. The 3 limit switches should be positioned such that the robot arm will home to the corner of the robot as shown in the above images. The 3 push buttons can be placed simply on a breadboard in the front of the robot.

The top button is used to tell the chess robot that the human player's turn has finished, the middle button will be to home the robotic arm, and the bottom button will be used to reset the change counter in case the magnets stick together while the human player is making their move.

Step 9: Computer Science - Arduino and Python

All of the code for this project is available on: https://github.com/RoboAvatar65/ChessRobot.

The two languages that were used for this project are Arduino and Python. The chess engine and algorithm is written in Python while code to control the robot itself is written in Arduino.

The Arduino code is responsible for detecting a human player's move and sending it to Python. Arduino is also responsible for receiving input from Python about which move the computer has chosen and executing the move by positioning the stepper motors.

The Python code is responsible for storing the required chess states such as piece positioning, castle rights, if the king is in check, etc. Python is also responsible for the minimax alpha beta algorithm which decides which move the computer will make.

Step 10: Computer Science - the Minimax Alpha Beta Algorithm

At 5:30 into the above How to Build a Chess Robot video, I explain the minimax alpha beta chess algorithm which is a variant of depth first search.This algorithm is used by the robot to decide which move it should make.

Step 11: Computer Science - Download the Code and Play Chess!

Download the Arduino and Python code from Github: https://github.com/RoboAvatar65/ChessRobot. After the code is downloaded, upload the ChessRobotControl.ino file to your Arduino Uno. Once that is completed run the Python program PlayerVsAi.py to play chess against the robot!

In order to play against the chess engine without a physical robot, change the robot parameter in the PlayerVsAi.py file to False. After, run PlayerVsAi.py to play against the engine!

Comments

author
jrbums made it! (author)2017-07-07

Awesome mechanical and electrical design, especially the gripper. It must have been difficult to design it for grabbing different shaped pieces.

author
inconceivable1 made it! (author)2017-07-02

O my gosh sooooooo cool! I love chess but i alwase do worse on the computer then i do on a board in real life. This could fix that problem! really cool.

author
DIY Hacks and How Tos made it! (author)2017-07-02

Awesome! You could use this system for all kinds of games.

About This Instructable

875views

23favorites

License:

Bio: Building awesome robots and technology for the world to see!
More by RoboAvatar:Automated Christmas LightsHomemade Chess Robot
Add instructable to: