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:
http://home.hccnet.nl/h.g.muller/max-src2.html
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*
Attachments
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
https://pythonrobotics.readthedocs.io/en/latest/mo...
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!
Attachments
CHESS_MICHALSKY_1.0.ino
CHESS.h
displayValues.ino
Map_ZERO_sud.ino
MashineMove.ino
moveServos.ino
Print_Moves.ino
Put_A.ino
Put_B.ino
Put_C.ino
Put_D.ino
Put_E.ino
Put_F.ino
Put_G.ino
Put_H.ino
reedSensors.ino
startReeds.ino
Take_A.ino
Take_B.ino
Take_C.ino
Take_D.ino
Take_E.ino
Take_F.ino
Take_G.ino
Take_H.ino
takeMove.ino
ShiftIn.h
Example_TwoShiftRegisters.ino

Participated in the
Robots Contest
43 Comments
3 years ago
Hello, nice project.
But do you have the gerber files for the pcb boards?
Best regards
Reply 3 years ago
Hi i am not an expert with fritzing i just created pdf and printet dem out
If you explain me how to create the files With fritzing then I will try
Reply 2 years ago
Hello,
Thank you for your answer. I found this Tutorial.
http://support.seeedstudio.com/knowledgebase/articles/1917928-how-to-generate-gerber-and-drill-files-from-fritzi
Does this help you? Can you now Upload the Gerber Files?
Question 2 years ago
Hello,
Can you upload the stl files from the updated Version?
And maybe the Gerber Files from the PCB Boards?
2 years ago
would it be alright if you posted a instructable on how to assemble the arm and platform if its ok thanks great project btw:)
Question 2 years ago
Hi, great project!!! Congratulations. I can't find the PCB-Boards attached as fzz-File(Fritzing), could you please upload these?
2 years ago
could you give me the files you used in your robot with uses coordinates, for me to modify, because I don't know how to do it from scratch
2 years ago
Reply 2 years ago
Just changing the function takeMove.ino insteat of waiting for select button just wait for a valid move and that is
Reply 2 years ago
// Take Human Move after pushing External SELECT Button
for(;;){
displayValues(); // Read values changed on Reed-Sensors and store result as human move
int val=digitalRead(inputPin); // Read digital input from External SELECT Button
if(val==LOW){ // If pushed then print -> human move is done then algorythm should run
lcd.setCursor(0,1);
lcd.print(" ");
printMN(mn, 1);
printMove();
break;
}
}
}
Question 2 years ago
Answer 2 years ago
I did the calibration with inverse kinematics with a separate code
Reply 2 years ago
Here you will find the code for the inverse kinematis
https://pythonrobotics.readthedocs.io/en/latest/mo...
Reply 2 years ago
Reply 2 years ago
There is no video tutorial but i can provide the sample code in Python
I will search for it and put it in descripción
2 years ago
CHESS_MICHALSKY_1.0:9:10: fatal error: ShiftIn.h: No such file or directory
#include <ShiftIn.h>
^~~~~~~~~~~
compilation terminated.
exit status 1
ShiftIn.h: No such file or directory
Reply 2 years ago
Try to put the library in the same folder as the main code
Reply 2 years ago
Reply 2 years ago
2 options:
The library file is missing or you didnt install it correctly
How you install libraries just find it in this link
https://www.arduino.cc/en/Guide/Libraries
2 years ago
Very nicely done. I would be interested to know whether you referred to my project as the implementation is very similar (https://forum.arduino.cc/index.php?topic=490965.msg3350275#msg3350275 and https://www.youtube.com/watch?v=svEf53gvRgc)?