Wooden Chess Board with Reed Switch Piece Recognition and LED move indicators

This site describes a fully working chess computer that recognises piece positions using reed switches and signals its move using a LED on each square.

It runs from an Arduino which controls the board, connected to a Raspberry PI which runs the chess engine Stockfish and a chess rules library called Chessboard. It is completely self contained, just plug it in, press the green button and you are playing.

Since building this version I have redesigned the hardware and I am part way through the build. This also creates the opportunity for getting a version of the board manufactured.  The new design is here

If you are not sure if you have the skills to build this project have a look at Beginners Start Here.

Key Features:

Play chess by moving pieces  and the computer signals its move using by flashing an LED

  • Stockfish chess engine with a maxiimum rating of GM with an ELO level around 2900
  • 21 levels of play
  • Set personality: agressiveness and cowardice
  • Play as black or white
  • Play human vs human
  • Validates moves against full moves of chess, signals error & allows re-move
  • Recognises and makes special moves: Castling; En Passent, Pawn Promotion
  • Provides hint if stuck
  • Option to save game as pgn

How it Works:

The next few pages explain how it works, there are two parts:

Harware: electronics and the board

Software: The programs that drive it

Why an Arduino and a Raspberry PI?

An Arduino is great for real time control of the devices on the chess board, but it does not use a conventional operating system like Unix/Debian/Raspian. Therefore Stockfish and most other strong chess engines won’t run on it. I believe there are a few chess engines that do run on Arduino http://chessprogramming.wikispaces.com/Arduino  , but they will not be as strong as Stockfish.

My interest in building chess computers started with Arduino and at the time the Raspberry Pi had not been released. Six months later it was and I realized I needed a different computer so I added the Raspberry Pi to run the engine.

If I was starting again today I would just use just the Raspberry PI with no Arduino,  and I explain how the new approach here.  However now that I have a great board that I can barely beat on level 3 out of 21, I have no reason to build another one.

I see that some people are designing robot arm playing chess computers, that sounds really cool. In that case I would use an Arduino to control the arm, board sensors etc and use a Raspberry Pi to run the chess engine.

Why the Stockfish Chess Engine?

Its the most powerful configurable Open Source multi-platform robust Chess engine

See here for more detail.

“I know what you’re thinking, punk. You’re thinking “is it mate in six moves or only five?” Now to tell you the truth I forgot myself in all this excitement. But being this is a 64 bit Stockfish, the most powerful chess engine in the world and will blow you defence clean off, you’ve gotta ask yourself a question: “Do I feel lucky?” Well, do ya, punk?”

 

Credits:

Original inspiration from these sites:

http://sishchess.blogspot.co.uk/p/building-sish-board-tutorial.html

Tony Whitby’s site, now defunct

Which set me off building a USB chessboard for connection to a PC based computer program. After that the next step was to build a complete chess computer.

41 Responses to Wooden Chess Board with Reed Switch Piece Recognition and LED move indicators

  1. Jimmy says:

    Hi.

    What a great project. I have a similar board that I have built. I’m using a teensy with some code from Berger’s Solus to monitor the board matrix, and I have written a stockfish interface in python also. I’d love to share what I’ve learned in the process and also learn more about your project. Thanks for the great video demo as well.

    Jimmy

  2. Michael Lang says:

    Hi,

    I would like to build this “Arduino RPi Stockfish” chess board. Is it possible to get more detailed information?

    Regards, Michael

    • maxim says:

      Michael,
      See my other two replies.
      I would suggest you start by building a Reed based USB board. There are detailed instructions for this on the site:
      Magnetic USB Chessboard (Solus Chess) see the links page. Berger, the guy that runs it has provided detailed wiring diagrams

      My other suggestion is that you may not be best to use an Arduino plus a Raspberry Pi. I used two because neither did a complete job.However new boards are coming onto the market every day and I have just ordered a “Beaglebone Black” board. That looks like it might do everything.

      I will add a post to the site when I know more.

  3. Michael says:

    Thanks Maxim,

    I will wait on your experience with the “Beaglebone Black” board!

    Try the “Mysticum” chesscomputer on my website!

    Regards, Michael

  4. peter says:

    hi where can I buy that chess computer?

  5. peter says:

    how much would a computer like this cost me?

  6. maxim says:

    You cannot buy this chess computer you would need to make it and program it.
    I hope to be able to publish how to make one with code on a Raspberry PI (see design ideas section).

    The cost of the electronic components will be about £90, the major costs are:
    Raspberry Pi £30.00
    Port Expanders £2
    4X20 serial lcd £21.83
    64 LEDs £5.12
    Breadboard £8.00
    64 Reed Switchs £20.00
    Magnets £3.99

    The prices for reed switches and LEDs are for 100 of each on ebay
    Plus wires & connectors.

    This assumes you make your own board and does not include the cost of the materials for the board and the pieces,

  7. koks says:

    Can you please post a video showing the inner part of the board and the bottom part.

  8. Ahmet says:

    how to solve “Pawn Promotion” problem, are you using additional button?

    • Max says:

      Ahmet, no real problem, the board has four colored buttons and a display (see section on hardware) when a pawn is eligible for promotion the system gives the alternatives: Q, R, B, K and the user chooses.

  9. Ahmet says:

    what your main Raspberry pi’s OS?

  10. Paddy says:

    Hi,

    I am attempting to make a chess playing robot, I would like to build an arm but I think this is beyond my capability so I am making a cartesian robot (similar to a gantry crane). I am not very experienced in this type of work and I have found your website very helpful. So what I am wondering, in comparison to your project would you advise that I use the raspberry to run the chess engine and the arduino to control the movement of the robot in the X, Y and Z axis?

    • Max says:

      Paddy, I think you could do it either way, but I would personally run the gantry crane from an Arduino and would use a motor shield like the excellent Adafruit shield to drive the motors: http://www.adafruit.com/product/81.
      you could do more than just x,y movement on the Arduino. For example you could have functions like : pickupiece(x,y), movearmto (x,y), placepiece(x,y), or more complex functions made up of functions like removepiece(x,y) or even castle(colour, Side) using this approach you could completely test the board separate from the engine. I would be interested to see how you get on. I think your biggest challenge will be to reliably pick up and place pieces.

      • Paddy says:

        I have the design for the robot completed including the grabber which I think will work well and accurately. I think I will be able to get the robot working well physically but I might struggle because I am very inexperienced when it comes to programming of any type. I have downloaded Python 2.7, Chessboard and Stockfish 5 but I do not know where I need to install each for them to run correctly.

        • Max says:

          I haven’t touched the code for over a year, but from what I remember Chessboard goes in the Python directory and Stockfish will end up in the right place if you use a standard Linux/Raspian install $sudo apt-get install stockfish. You then need to make sure you use the right file name in your Python program. you say you are “very inexperienced when it comes to programming of any type.” Maybe you should work through the book “Python Programming for the absolute beginner” by Michael Dawson. It will teach you lots of the things you need to know for your project.

          • Paddy says:

            Max, do you think this project would work as well if I excluded the Raspberry Pi altogether and ran the Chess engine off of my computer, connected to my the arduino? I am finding using the Raspberry Pi quite difficult and am hoping to make the project a bit easier to complete.

            • Max says:

              Paddy. Connecting from a computer is the same a connecting from a PI. I suggest you approach this step by step. First are you able to communicate between the Arduino and a simple Python program running on the PI? if you can’t here’s how: http://playground.arduino.cc/interfacing/python.
              If you can do that then on the Pi (or your computer) you will still need to write a Python program that manages the chess engine and the ChessBoard library if you are going to build a self contained chess computer. The example Python program on this site gives you the bare bones for doing that.

  11. Amey says:

    can you provide a source code for rasperry pi??

    • Max says:

      Sorry, I do not provide source code, however there is enough detail and references on the site to enable you to build your own version.For the Raspberry PI Python program, the site has a listing of a demonstration Python program that plays chess, which is 80% done. You just need to adapt it for your purposes.

  12. Eric Warolus says:

    Congratulations on achieving your chessboard.

    For some time, I plan to build a chessboard with USB port (Berger soluschess) adding LED on a wooden chessboard.
    This board can be connected to a PC, tablet or raspberry pi.

    Your website is very good informative, already thank you for all that information.

    For the detection and display, I’ll buy the electronic components

    a teensy ++ 2 (enough for dectection square, but for the lighting of LED?)
    the reed switches,
    magnets.

    Can you just give me more information
    about Port Expanders £2 and Breadboard £8 ?

    I just got a rasbperry pi 2.

    greetings

    • Max says:

      I control all the LEDS using the MAX7219CNG LED display driver (port expander). To drive the MAX7219 you need only 3 pins from the Arduino.
      See this link for an example tutorial.

      The breadboard is just to hold the MAX7219 and join the connections not very elegant.

      • Eric Warolus says:

        Thank you for your quick response.
        I do not plan to use an Arduino.

        If possible, the connection between the board and PC, tablet or Rasperry ft 2 is made only by the USB port.

        To your knowledge, there is a micro controller USB programmable that manages the detection of movements and the lighting of the LED?

        Thank You

        • Max says:

          Yes the best micro processor to use to control the board and connect via USB is an Arduino. I used an Arduino UNO but I think either and Arduino nano, or a Teensy might be better.

  13. Paul says:

    Hi,

    Thanks for putting up your excellent work.

    I pretty much have the python you have made available adjusted for what I need and found it was a great start for interfacing between a UCI engine and the ChessBoard module.

    Do you have any objections when I am done of me making my version of the code publicly available (with due credit to yourself of course)?

    Cheers

    Paul

    • Max says:

      Paul, no objection to you publishing code, mine was also based on the work of others. What is the URL of your site, I am interested inthe architecture you used for the board. Max

      • Paul says:

        Hi Max,

        I haven’t put anything online yet and at the moment am getting the software sorted out – need to set the skill and cowardice/aggressiveness options. I have only been working on this a few days and am happy it is working with Stockfish 6 which needed compiling from source and has hooks in place for input from board, output to board/display as appropriate.

        Next job is the electronics, at the moment I think I can treat the board inputs as an 8×8 keypad on the RaspberryPi using an I2C port expander – so can avoid having to add a Teensy or Arduino into the mix. LEDs – have decided to go for 16 LEDs side/bottom rather than each square – again driven off I2C. For a display I am likely to use a 128×64 OLED display with yes an I2C – in theory I can use 7 MCP23017s…

        Once I am happy with the code/electronics side of stuff I then intend to build/bastardize a board.

        Its early days at the moment, parts are incoming from China etc and I am in no rush as this is for fun.

        Once stuff starts going online (in a few days I guess) I will let you know the URL.

        • Max says:

          Paul, Your approach should work and the port expanders should give you enough connections. You will be aware that you cannot treat the chess board as a simple 8×8 matrix as in play some reed switches will already be activated because they already contain pieces. This leads to “ghosting”. You will need to add diodes see: https://sites.google.com/site/bergersprojects/reedcb/matrix
          Treating the board as a matrix is the more elegant solution. However I hate soldering and once you add in the diodes you end up with 4 soldered connections per square. (two each for the diode and reed switch) I ended up going for the the brute force option using a I2c centipede board which allows for 64 direct connections. More wire, but only 2 solders per square and very simple testing. It connects by ribbon cable so the wiring is simple. Then in software I can directly address each square.
          For the LEDS I went for the full 64 which you can treat as a simple matrix, because only one is on at any one time and with the MAX7219CNG LED driver its easy to wire.
          But it sounds like you are on the right track. Please keep me informed.

        • adam says:

          hello paul,

          How’s it going with the chess board project? Is it still underway for publishing? would like to build a stand alone board as well.

          wish Max would post a tutorial on his build. 🙁

          Thanks Max and Paul for the work you’ve shared and/or are planning to share! 😀

  14. Narayanan B says:

    Max,

    Very nice project and beautifully executed! I would like to build one as well and have questions regarding the design and placement of Reeds. I live in the US. Can I call you at a time that’s most convenient for you? This should not take more than 15 minutes.

    Thanks,

    Narayanan

  15. James says:

    Okay, this is great. I had a kasparov chess computer in the 80s and it was the bomb when I was at school, although got very slow at the higher levels and I kind of outgrew it.

    Now I have young kids getting into chess and I would love to buy a cool wooden chess computer like this. I swear there is a market for this – seriously think about putting something like this up on kickstarter.

    A great side project – you could seriously pump out a few hundred of these a year …

    • Max says:

      I looked at this. Until a few years ago you could buy good quality wooden chess computers, but since the advent of PC, Phone and tablet chess programs, the market for them has collapsed. You can still get them on ebay.

  16. Adrie says:

    Hallo,

    Very nice,

    Can I buy a nice Board, please?
    Or can you make one?

    Thanks,

    Adrie

    aavandernat@quicknet.nl

  17. Max says:

    Adrie,
    I am afraid you will need to make your own. I do not sell or make for others. Alternatively you could buy a wooden Mephisto Exclusive Chess computer on ebay. They are not made any more and go for around £200. They are not as strong as Stockfish, but will beat most players.

  18. Hi,

    I wondered if it would be possible for you to write more detailed instructions so that we could copy your design? I’m particularly interested in how you set up the wiring. I have done some simpler Raspberry Pi projects, but nothing this complex so far.

    Thanks!

    Jennifer

    • Max says:

      Jennifer. I have redesigned the chessboard with a simpler design. However there is still a lot to be done. I suggest you start by trying to wire up a simple 3×3 grid, perhaps building a tic-tac toe game (Noughts & Crosses in English). The MCP23017 controls the reed switches and the HTK1633 controls the LEDS. I will put up more detail on the page in the next week or so.

  19. Brian says:

    I have built a board similar to this, and would like to offer a few thoughts from my experience.
    I initially mounted the reed switches horizontally, but found them to be very hit and miss because they are activated by the magnet at each end of the switch rather than the centre. Mounting them vertically works much better.
    Although it can all be done with the Rpi, I still used an arduino on the board because it can then be used to connect to Pi or to a pc running Arena. Would also be easy to upgrade to other single board computers that may become available.
    I wanted the leds to light on four corners of the selected square, but you then need a 9*9 led array. I used 2*MAX2719 kits and dumped the led matrix that they were supplied with..
    I modified the open source picochess (https://github.com/jromang/picochess) on the raspberry pi to interface with my diy board. and it works really well, although I don’t yet have all the functionality working correctly.
    For the board I used a wooden tournament board from ebay (£22).
    drilled 3mm holes at each square corner for the led’s and another hole from the back of the board in the centre of each square (not all the way through) to mount the reed switches and diodes
    To allow space for the electronics and wiring under the board I will add wooden mouldings around the edges.

Leave a Reply

Your email address will not be published. Required fields are marked *


*