Introduction: How to Built a Chess Robot With Arduino Mega

I also made an upgrade of this robot with 4-DOF(degrees of freedom) instead of 6-DOF that you see in the video, the movements and the calculation of inverse kinematics is less complicated but a 3D printer is needed.

The board executes micro-Max source code, allowing you to run chess logic on an Arduino Mega and execute the proper moves with a 6DOF mechanical arm.

The setup uses magnetic pieces and below the board an array of 64 reed switches and 8 shift registers. This allows to capture the movements of the pieces on the board. The signal from the switches is transmitted to the Arduino Mega which calculates the best possible movement using the Micro Max algorithm.
The Arduino Mega operates a mechanical arm accordingly, performing the indicated movement

Find the Micro-Max Chess Source Code algorithm on the link below:

The Algorithm has an ELO of arround 2000

2400 and above: Senior Master

2200–2399: National Master

above 2200: Original Life Master

2000–2199: Expert or Candidate Master

1800–1999: Class A

1600–1799: Class B

1400–1599: Class C

1200–1399: Class D

1000–1199: Class E

800–999: Class F

600–799: Class G

400–599: Class H

200–399: Class I

100–199: Class J

Step 1: Electronic Components

  • 1 x Arduino Mega
  • 1 x AZDelivery LCD1602 Display Keypad Shield HD44780 1602
  • 1 x PCA9685 12bit PWM Servo Motor I2C Controller
  • 1 x DC-DC 5A 75W step down converter
  • 8 x 74HC165 Shift Registers
  • 64 x Reed Sensors
  • 64 x 10kOhm Resistors
  • 1 x Mechanical Kit Robot arm 6-DOF
  • 5 x 10 kg/cm torque 180deg Servo Motors
  • 1 x 20 kg/cm torque 180deg Servo Motor
  • 1 x Electronic plastic project box
  • 1 x Power Jack Connector
  • 1 x 12V Power Source at least 5000mAh
  • 4 x 150x150mm PCB Board with single sided copper
  • 4 x 100x70mm PCB Board with double sided copper
  • 1 x Chess board 320x320mm (40mm box size) and chess pieces with magnet
  • Wood for the base

Below you find a link to the robot-arm with servos

Step 2: PCB-Boards

PCB-Boards are attached as fzz-File(Fritzing) as well as pdf-File, just print them out and follow the link below to learn how etch multilayer PCB-Boards:

*Video below is from another project*

Step 3: Wiring

*You can put a speaker optional and fit to the correct pin in the code and Arduino shield, it will sound for example if you do a not valid move*

Step 4: Assembly

It is just an Assembly with wood

Step 5: The Code

The Code has two different main programms:

Main functions roughly explained:

First Main Programm: CHESS.h is the main program for the algorithm (!!! DO NOT CHANGE ANYTHING HERE !!!)

Second Main Programm: CHESS_MICHALSKY.ino is the main program to call sub-functions

Into /* Arrays for Servo coordinates */

Load the code and fill the values for all arrays to fit to your robot dimensions by calculating each movement with inverse kinematics because of accuracy for all 64 fields of the chess board and because every robot arm has different dimensions, fields are blank to be filled by your self

Information about inverse kinematics can you find everywhere:

the link below for example

Example for coordinates to move the arm till over the square B5:

int B5u[6] = {t[0]+72, t[1]+85, t[2]+89, t[3]+113, t[4]+56};

Example for coordinates to move the arm down to take the piece on square B5:

int B5d[6] = {t[0]+0, t[1]+80, t[2]+114, t[3]+95, t[4]+0};

Example for coordinates to take a piece out of the field:

int OUTu[6] = {t[0]+38, t[1]+60, t[2]+60, t[3]+108, t[4]+85};
int OUTd[6] = {t[0]+0, t[1]+83, t[2]+120, t[3]+101, t[4]+0};

with array t[] servos can be trimmed with high accuracy

Into /* My variables */

change the start Position for Servos to fit to your robot

int Zero[6]={100,140,117,135,75,110};

int openPincers = 93;
int closePincers = 126;

Sub-Functions roughly explained: (DO NOT CHANGE ANYTHING HERE !!!)

startZERO(), startUP(), startDOWN() and mapValues() -> define Start coordinates for movement from Zero, upper and bottom position of Servos, Map all values for Servos.

startReeds() -> this function initialize all reeds at the beginning

displayValues() -> this function is continuously checking if there is a change on the board and reading values from the registers

takeMove() -> this function confirm human move after pushing SELECT Button

reedSensor_start() -> this function reads the start-square of a movement

reedSensor_target() -> this function reads the target-square of a movement

  • // x1 is variation of start reed sensor in letters row -> row1=a, row2=b....
  • // y1 is variation of start reed sensor in numbers columns -> column1=0, column2=1...
  • // x2 is variation of target reed sensor in letters row -> row1=a, row2=b....
  • // y2 is variation of target reed sensor in numbers columns -> column1=0, column2=1...

See also picture above !!!

printMove() -> this function print coordinates on LCD calling reedSensor_start() and reedSensor_target()

printLastMovs() -> this function print movements on LCD calling the algorithm

Sub-Functions roughly explained: (CHANGE VALUES HERE TO FIT TO YOUR ROBOT !!!)

servosToZero() -> this function move Servos to start position (set your start coordinates for the servos)

tOut() -> this function take a piece out of the board, counter c is for more accurate movement (set your coordinates for the servos)

openP(), closeP() -> this functions open and close the pincers (set your coordinates for the last servo with pincers)

Sub-Functions to set the position of servos

Almost all of the functions are blank so you can fit the movements for each field to your robot

Example for the movement to take or put a piece on square B5 is in the Code

pB5() -> this function put a piece on square B5

tB5() -> this function take a piece from square B5

You need to download the ShiftIn library also

and make sure to put 8 for the instance with a 8 chips ShiftIn<8> shift;

if you don't know how use the library download the example with 2 registers to understand how it works

If I made some mistake in explanation please let me know thanks!

Robots Contest

Participated in the
Robots Contest