How to Built a Chess Robot With Arduino Mega

6,216

91

41

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

https://www.ebay.de/itm/Manipulator-Roboterarm-6-D...

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

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!

Robots Contest

Participated in the
Robots Contest

Be the First to Share

    Recommendations

    • Arduino Contest

      Arduino Contest
    • Explore Science Challenge

      Explore Science Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest

    41 Comments

    0
    Builder200
    Builder200

    4 weeks 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:)

    0
    videojuegosclub2019
    videojuegosclub2019

    Question 4 months ago


    Hi, great project!!! Congratulations. I can't find the PCB-Boards attached as fzz-File(Fritzing), could you please upload these?

    0
    jucal3889
    jucal3889

    4 months 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

    0
    jucal3889
    jucal3889

    5 months ago

    has a way to make it 100% automatic by removing the select button?
    0
    Michalsky
    Michalsky

    Reply 5 months ago

    Just changing the function takeMove.ino insteat of waiting for select button just wait for a valid move and that is

    0
    jucal3889
    jucal3889

    Reply 5 months ago

    sorry i'm very new to programming u could make the change for me
    // Take Human Move after pushing External SELECT Button
    void takeMove(){
    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;
    }
    }
    }
    0
    jucal3889
    jucal3889

    Question 5 months ago



    it was because it was like this <ShiftIn.h> I changed it to "ShiftIn.h" it worked




    0
    Michalsky
    Michalsky

    Answer 5 months ago

    I did the calibration with inverse kinematics with a separate code

    0
    jucal3889
    jucal3889

    Reply 5 months ago

    make video tutorial please
    0
    Michalsky
    Michalsky

    Reply 5 months 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

    0
    jucal3889
    jucal3889

    5 months ago


    how do i resolve this error





    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

    0
    Michalsky
    Michalsky

    Reply 5 months ago

    Try to put the library in the same folder as the main code

    0
    jucal3889
    jucal3889

    Reply 5 months ago

    I already did it but it didn't work
    0
    Michalsky
    Michalsky

    Reply 5 months ago

    Hello, your project do I see for the first time, it looks also great
    But no, this is my own project you can check also the upgrade I made

    0
    drBen2000
    drBen2000

    Question 7 months ago

    Hi, did you modify the robot arm? In the video does it look like the arms are extended? If so, it would be great if you could tell me what exactly was done or how long the arms are extended. Thank you so much! I will start building now ...

    0
    Michalsky
    Michalsky

    Answer 7 months ago

    Hi,
    Yes I modified the arm about 250mm with an aluminium profile and some reinforcing bar spacers so that the whole board can be reaches
    Just test which length fits best for your robot arm kit and adapt the coordinates in the code as well

    0
    BluRay_123
    BluRay_123

    7 months ago

    Hello, nice project.
    But do you have the gerber files for the pcb boards?

    Best regards