How to Build an Arduino Powered Chess Playing Robot

 by mJusticz
Contest WinnerFeatured
DSC_7851.jpg
DSC_7841.jpg
Judging by the sheer number of chess related Instructables, I think it's safe to say the community enjoys the game.  It can be difficult, however, to find someone who plays on the same level you do.  To solve this dilemma, and to increase my playing skills, I built this arduino powered chess playing robot.

**UPDATE**  PCWorld just posted about this project on their blog! Thanks, guys!
This project is entered in the 13-18 division of the robotics week contest.


The board works like any other xy table, with a few key differences.  First, the x axis has an extra servo attached to it, which raises and lowers a magnet.  The magnet is attracted to pieces on the chess board above, allowing them to move.  Second, embedded in the board are 64 magnetically activated reed switches, allowing the arduino to know the location of each piece. 

What I love about this project is its adaptability.  If you decide you're done with it as a chess board, it can instantly convert into a CNC mill by modifying a few pieces.  I'll talk more about this possibility at the end.

All in all, while there was definitely some great novelty in watching the computer move pieces around with the board, this project was not as successful as I had hoped.  The magnets were way too powerful, so extra pieces would often get drawn in when they shouldn't have.  I think with some changes this could have been an even better, more functional project.  However, I think this Instructable still serves as a pretty good guide to make your own functioning chess playing robot.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts and Materials

a.jpg
You may have many of the parts for this project already, but if you don't, the whole list costs ≈ $350, depending on where you get your parts from.  Many, many of them can be salvaged, so look to recycle before you buy!
  • 1 Arduino Uno or Diecimila
We'll be using this arduino to drive our stepper motors and servos.  You can pick these up just about anywhere online.  I got mine from Adafruit. $30
  • 1 Arduino Mega
This is the most expensive item in the project.  It'll be dealing with the inputs from each chess square to let the computer know where you've moved.  We're using the mega here due to its speed and number of inputs.  Adafruit $65
  • 1 Mux Shield
The mux shield (short for multiplexer) gives us even more inputs for our arduino mega.  We'll need 64 inputs in total, one for each square.  Sparkfun $25
  • Motor Shield
The motor shield will be controlling our stepper motors and servo.  You'll need to solder it together.  Adafruit $19.50
  • 1 Large chess board with pieces
This one is a little more self explanatory.  We want a large chess board here because the pieces need to be able to move in between each other with disrupting others.  Make sure you measure the diameter of the bottoms of the pieces.  We'll need that in a moment.  I'm not sure where mine is from, but you can pick them up from a flea market for a bargain.  The playable area of my board is 24".
  • 64 NO Reed Switches
Reed switches are magnetically activated switches.  They'll help us find the location of moved pieces.  NO stands for normally open, that is, the circuit is disconnected   Digikey ≈$30
  • 16 10K 1/4 Watt Resistors
These are the pull up resistors for the built in digital pins.  The mux shield, luckily, has integrated pull downs, so we don't need to worry about those. Digikey ≈ $2
  • Roughly 90 feet of 30AWG Wire

This is the hookup wire for all of our sensors. Radioshack ≈ $16
  • Neodymium Magnets to fit your pieces
This is where the measurements from the bottoms of your chess pieces come in handy.  You'll need disc magnets to fit underneath each piece.  For proper strength, they should be about 1/8" think.  A great source for these is K&J Magnetics.  ≈ $55
  • 1 Large Neodymium Magnet
This magnet will be attached to the XY table underneath the board, to move each piece around.  K&J Magnetics $19  Note: This was Waaaay too powerful.  It would draw in pieces it shouldn't have.  You'd be better off going with some smaller ceramic magnets, like you'd find at Staples or another office supply store.
  • 2 Pairs of 24" Drawer Bearings
The size of your bearings will depend on the playable area of your chess board.  These allow for the stepper motors to move back and forth underneath the board. Amazon ≈ $30
  • 2 Stepper Motors
Stepper motors can move in very precise increments.  In the late 90s they were in just about every piece of tech you could find.  The best place to get these are in old dot-matrix printers.  You can them at the flea market for next to nothing!
  • 2 Vex Rack and Gear Sets
The rack gears allow the stepper motors to travel on the drawer bearings.  See the Step 4 for a more detailed explanation.  Vex Store $40
  • 1 Standard Hobby Servo
This servo will be raising and lowering the powerful magnet below the board. You can find them at a hobby shop for ≈ $10, or Amazon ≈ $12
  • 1 2' x 2' Perf Board
The perf board is super thin and will be the mounting surface for all of our reed switches.  The price will vary greatly on this one, but I got mine from Home Depot for ≈ $5
  • 1 2' x 2' x 1/2" MDF Board
Similar to the perf board, I got this from Home Depot for  ≈ $5
  • Various lengths of scrap 1"x2" wood
This wood forms the bridge between the X-Axis drawer bearings.  Go behind any hardware store and you'll see dumpsters full of this stuff for totally free!
  • 5 Minute Epoxy
This stuff is a godsend.  It's used for just about everything in this project, from mounting motors to attaching the rack gears.  I'm in love -- and  I picked mine up from Radio Shack for $3
  • 1 Wood Saw
You probably already have this one, but if you don't, I picked mine up at Ace Hardware for $10 a couple of years ago.

1-40 of 53Next »
Ramssess94 says: Mar 28, 2013. 7:50 PM
Where i can download the code of XY??
in my computer out korean letters
Vogonslurp says: Dec 9, 2012. 12:08 PM
Hi Max
I love your project, it's just such a good idea!
I have a question regarding the coding though. What changes have to be made to Sjeng in order for it to function? I'm more of a java person, but I do know a little C. I have Windows, so unfortunately no Mac.
Thanks!
MrRoboBrain says: Nov 20, 2012. 4:09 AM
Nice project man, good work and idea! My advice for one of the changes would be to change your magnet with electro magnet.
something1 says: Nov 3, 2012. 11:45 PM
I was wondering how does the arduino get instructions from the chess engine and how does it send a move please tell me I need to know.
will3675 says: Oct 21, 2012. 12:01 AM
Really cool project but what does it do with a piece like the knight that might have to jump over other pieces?
Mohammad_badawe says: Oct 11, 2012. 8:38 PM
Hello! thats a great project man ! i'm a 4th year mechatronics engineer and i wonder if i can program this arduino on PC cause i don't have mac ! plaz help me with this :) thank you anyway
crabbypup says: Aug 21, 2012. 3:30 PM
for everyone still looking for the sjeng application, you can find it here: http://sjeng.org/indexold.html

also, where is the code to program the two arduinos? and are the arduinos attached just by USB, or are they wired together first? the 'ible isn't really clear on this. thanks!
diy_bloke says: Jul 4, 2012. 11:31 AM
impressive. I am not gona build this, but I have been thinking about a raised 4x4 ft plant bed in which individual plants would be watered via a similar setup. Would not be moving chesspieces but a nozzle. This has given me some idea's
amirhemat says: Apr 19, 2012. 7:18 AM
hello
i am
amir hemat
iran
plz add me
tanx
cheukhengc says: Feb 20, 2012. 4:20 AM
If the horse need to jump out on the first step, how will it move?
tjesse says: Sep 2, 2011. 9:38 PM
Can't wait to see what you will do next. How is the laser?
mJusticz (author) in reply to tjesseNov 29, 2011. 7:25 PM
It's pretty fantastic!
masterzeb318 says: Oct 24, 2011. 5:54 AM
but what if your chess set is wood?
mickey12vt says: Jul 12, 2011. 9:48 AM
That's awesome.
tinker234 says: Jun 29, 2011. 11:35 AM
hey at think geek . com they are selling harry poter chess set be cool to make a program so i can say e4 to ee5 something like that
WizenedEE says: Apr 30, 2011. 2:50 PM
Why don't use the integrated pull up resistors in the arduino (a digitialwrite on a pin does it) instead of using external ones?

Also, couldn't you use just one arduino? The mux shield can go on top of the motor shield. They both use pin 2, but you can cut the trace and rewire it, and that costs way less than $30. Even better, you could add a fourth multiplexer and use just one uno.

This project is really cool, though.
scottinnh says: Apr 25, 2011. 8:31 AM
Congrats on a well done and ambitious project.

When will you have the upgraded version which allows 2 player over the Internet? [grin]
samedirection says: Mar 20, 2011. 5:03 PM
Very cool project. It'd be nice to see more than a few seconds of video of the thing actually moving the pieces, though. How well does it handle a knight jumping over other pieces? Can it castle? Do you ever have to 'help' it? (Besides, say when 'queening' a pawn). Can it move a bishop across the long diagonal through a crowded board?
mJusticz (author) in reply to samedirectionMar 20, 2011. 5:15 PM
Thanks! As far as moving in between pieces goes, it doesn't "jump." Rather, when it wants to move by pieces it goes in between rows. In the code you'll see I've added a couple of lines since I shot the video that move a half square before moving any pieces. I haven't needed to move for it so far (knock on wood). The drawer bearings I've bought are nice enough that they don't really get stuck. Castling works like any other move. The chess algorithm called Sjeng takes the movement of the king over two squares as an automatic castle, so there's no need to add any special code. Bishops can move a long distance quite easily, because the pieces are small enough that moving half a square over guarantees a free path.
mdon in reply to mJusticzApr 15, 2011. 5:08 AM
Hmm just wondering whether this sol. works....i.e., before moving the knight, move the crowded pieces to empty spaces and make the code remember these changes and revert back when the knight is moved. It would look like a witch spell moving things around :-) :-) ...........

by the by its a great project, but can we scale down the size?
mJusticz (author) in reply to mdonApr 16, 2011. 8:33 AM
That would definitely work, but would take much, much longer than the current solution with this setup. Go for it!
MBurg says: Apr 7, 2011. 11:36 PM
When a piece is captured do you just remove it from the board? Also can you just lift up your piece and place it on the spot you want to move to or must you drag it on the board? I am guessing the size of the chess pieces matters you want them small enough to move by other pieces. I hope I try this out, also would like to add support to be able to play against people online and be able to use the board just like one of those DGT eboards they don't move the pieces for you tho at what they want for them they should.
mJusticz (author) in reply to MBurgApr 10, 2011. 3:05 PM
Yes, you must manually remove the captured piece. As far as moving pieces goes, the latest version of the code does it based off of a timer-- once you move a piece, it starts, and wherever the piece ends up at the end of three seconds is the second square. So you could slide or tap all over the board and only get the move you intended. The size of the chess pieces does matter, as each piece must have a diameter of at most one half of the square.

Glad you're building it! Make sure to send photos when you're done!

Max
MBurg in reply to mJusticzApr 12, 2011. 3:47 AM
My current chess board looks very close to yours. I am worried that the reed switches on the bottom wont get triggered by the magnets. Did you have any problems with this? I am also going to try and use shift registers. You posted this at a great time, I was thinking about buying a board that moved it's pieces but you have to push down on the board and it's rather loud.
mJusticz (author) in reply to MBurgApr 12, 2011. 6:56 PM
I haven't had trouble with triggering, though I'll occasionally have to wiggle a piece. Unfortunately my advice is fairly obvious: get powerful, high grade magnets from a reputable source (I like K&J), and use a relatively thin chess board. Good luck!
sponges says: Apr 6, 2011. 5:13 PM
Congrats! :)
mJusticz (author) in reply to spongesApr 8, 2011. 10:32 AM
Thanks! I ordered some ferric chloride for my business cards :)
grenadier says: Apr 6, 2011. 1:50 PM
:'(
ben_k says: Apr 6, 2011. 7:25 AM
Congratulations on winning! Have fun with the laser cutter.
ynze in reply to ben_kApr 6, 2011. 8:52 AM
Congrats! Great idea and I'ble. Have fun laser cutting!
SolarPoweredGardener says: Apr 6, 2011. 6:55 AM
Congradulations...Enjoy your prize....
aleceatsfood says: Apr 3, 2011. 4:27 PM
Awesome! I'd love to see a longer game though! Who ever said you couldn't play chess by yourself!?!? =D
NoseyNick says: Mar 27, 2011. 5:11 AM
Not bad! Personally I'd have saved the cost of the Mega by adding a shift register to the uno though.

Instead of 64 seperate inputs, you'd need 8 row wires, 8 column wires... 2 arduino outputs go to "clock" and "ser" on a shift reg (EG 74HC595) so you can choose to power one row at a time. Connect each square as row-reedsw-diode-col. Then the 8 cols go to 8 arduino inputs... or even through the other type of shift register if you need to reduce that down to 3 pins.

64 diodes and a shift register are much cheaper than a mega, and your wiring is likely to be neater too. Really cool project though, thanks for sharing! Love the XY construction, makes me wonder why this technique isn't used for CNC projects (much? at all?) :-)
mJusticz (author) in reply to NoseyNickMar 27, 2011. 6:21 PM
That's a really excellent suggestion! I'll try that should I ever revisit this project. Yeah, I've always wondered why more CNC tables don't use this gearing technique.
Purple Guy says: Mar 26, 2011. 9:44 AM
Great, but it would be nice to see some more moves?
chicopluma says: Mar 25, 2011. 6:18 PM
wow the computer realy moves the peon awsome
NitroRustlerDriver says: Mar 24, 2011. 3:25 PM
To unsure a perfect hole with the hole saw and have no tear out, drill through one side until only the center pilot drill breaks through. Then flip the part over and finish drilling.
mJusticz (author) in reply to NitroRustlerDriverMar 24, 2011. 5:41 PM
That makes a lot of sense. Thanks!
boltfox20 says: Mar 24, 2011. 8:10 AM
I remember having one of these. I had a chess board that worked off of magnets and was attached to a tiny computer. Unfortunately it was crash happy. Kept giving me a 601 error, whatever that was.

I'd love to have another real-life computer chess opponent. Too bad I am no good at these projects. ^_^;;;

Looks great. I hope you win.
mJusticz (author) in reply to boltfox20Mar 24, 2011. 10:48 AM
Thanks, that means a lot!
1-40 of 53Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!