Electronic – Making an electronic chess board

detectionmatrix

I want to make a wooden chess board that you can play on with regular pieces (i.e., not modified pieces that make use of RFID codes, magnets, …), but that is connected to a software that takes notice of my moves and acts as the second player.

I have been thinking about how to detect pieces on the board, and I have made the decisions that I do not need to recognize which piece is where: The "truth" is within the software, so if I move a piece from A to B, the software is able to find out which piece was moved.

So, I had the idea to drill two holes into each field of the chess board, one in the center, and one in the upper right corner:

  • The one in the center will be used for a brightness sensor to detect whether a piece is standing on the field or not.
  • The one in the corner will be used for an LED to show which piece the user has to move for the computer, so that the real-world situation matches the software situation again.

I want to use a Raspberry Pi as hardware foundation for the software to run, which will be written in Node.js (but that should not be important for this question).

So, what I end up with is 64 brightness sensors, and 64 LEDs, that I need to address individually. In other words: I need 64 outputs, and 64 inputs. And of course this is something a Raspberry Pi does not handle out of the box – and I think that there has to be a better way than to have 128 I/O ports.

Since I think that detecting the board's state is the more important task, I started to search the web how to handle a 8×8 matrix of switches. I found the suggestion to use a micro controller that scans the columns of the board sequentially, and in each columns detects whether a row (= a field) is used or not.

This would reduce complexity to having 8 outputs and 8 inputs (to be able to read the board's state).

On this, I have a few questions:

  1. Are my thoughts right, i.e. is this the correct approach, or is there a better alternative that I should watch out for?
  2. As I have no experience with micro controllers, what do I need to look out for? Do I just need a micro controller with 16 pins, that is programmable in a language that I am able to write, or …?
  3. Has anybody built such a board and has some advice or knows of a tutorial that walks you through the process?

Best Answer

Since an image is worth a thousand words, here's an example of LDM-24488NI: a 64-led matrix

enter image description here

For your application you will need one such matrix for LEDs, and another one for sensors, requiring a total of 32 IO pins. Since your RPi doesn't have that many, you will have to use 1-to-8 demux to select individual rows and columns:

enter image description here

For LEDs, you can use demultiplexers for both rows and columns, since you only need one led at a time. For sensors, I'd recommend using a demux for rows and individual lines for columns, to be able to detect multiple active sensors in one row. That will bring the required pin count to 17 pins, which an RPi can handle.