Smart Chess Board

by hubeknaepkens in Circuits > Raspberry Pi

372 Views, 0 Favorites, 0 Comments

Smart Chess Board

poster_frederik.png

This instructables is going to help you replicate a Smart Chess Board I made for a school project. The chessboard has 2 ways you can use it: A Player v Player and a Player v Computer mode. Every played game is stored in a database and can be reviewed afterwards on a website. On the website is a chess engine used to rate the positions and give the best possible move so you can learn from your mistakes.

Supplies

Case:

  • MDF 9mm 61x60
  • MDF 18mm 61x200
  • Acrylic chessboard
  • Chess pieces

Electronics:

  • Raspberry Pi Model 4B
  • LCD-display 16x2
  • TCA9548A I2C Multiplexer
  • MCP23017 (4x)
  • Reed switch (64x)
  • Adafruit 16x8 Led Matrix Driver
  • Led (64x)
  • Neodymium Magnets 10mm x 1mm (96) --> depends on board thickness
  • Resistor 470 Ohm (64x)
  • Potentiometer
  • LDR
  • Switch (2x)

Assembly:

  • Soldering station
  • Soldering wire
  • Jumperwire cables
  • Wire +- 40m
  • Drill
  • Wood saw (only if MDF isn't in correct measurements)
  • Hot glue gun

Case

TempBehuizing_1.jpg
TempBehuizing_2.jpg
TempBehuizing_3.jpg
TempBehuizing_6.jpg

Take your MDF plates and cut them into the correct sizes.

Sides: 120mm x 610mm (18mm)

Bottom: 610mm x 610mm (18mm)

Top: 610mm x 610mm (9mm)

Screw The sides and bottom together. Other ways of holding the planks together is also fine, use what works best for you.

Drill holes in the sides for the potentiometer and buttons. The exact measurements are in the PDF file below.

Now drill all the holes for the led's in the top. The correct measurements are also in the PDF file below. Don't mount the top permanently on the rest of the case yet. First we need to some soldering (a lot) and the electronics.

I will also include the 3D model of the chessboard. Maybe it's useful to some of you to get a better understanding of how it's supposed to look.

LED Matrix

LedMatrix2.jpg
8X8-Matrix-Pinout_Cut.png

The schematic of the Led matrix is pretty straight forward. You have 16 wires in total, 8 rows and 8 columns. You should probably watch a video on how a led matrix works so you don't accidentally solder something wrong incase you don't already.

I folded the legs of my led's in advance so its easier when soldering. Place all the led's in the holes you drilled in the top so they stay in place and get to soldering.

This step isn't very hard it just takes up a lot of time so be prepared :)

I included the whole schematic below. Just look for the big led matrix if the image on top isn't clear.

Reed Switches

Remove the led matrix from the top and put it to the side for the this step.

In this step you are going to glue all the reed switches to the top and solder wires to them. Its very useful to draw the squares of the chessboard on the back of the top where the switches will be to position them correctly.

Place every reed switch in the bottom right corner of a square (shown on image) and hot glue it in place. After doing this for all the switches, Cut wires to the correct length and solder all the negative sides together on 1 wire. You can do it how you want but using my method by looking on top is the best in my opinion. Now cut wires to the correct length again and solder them on each remaining leg op the switch. !!!NOT TOGETHER!!! and bring them to one side of the board.

After doing this I found it useful to hot glue the legs to the switches to the top as well so when moving the wires the legs don't accidently break.

Miscellaneous Electronics

In this next step you will connect the LDR, potentiometer and LCD to the raspberry pi. This step is quite easy just follow the electronics schematic. The LCD is connected via I2C and will only require 4 wires. Connect Vcc to the 5v and GND to the ground of the Pi. SDA and SCL go to the corresponding pins on the Raspberry Pi, GPIO2 and GPIO3 accordingly.

The LDR and potentiometer have an analog signal as output so we will need an analog to digital converter (ADC) in order for out Pi to read these value's. The ADC I recommend is the MCP3008. This device is connected via SPI to the Pi. Look at the datasheet or my schematic for a proper explanation on how to connect this device. Plug the output of the 2 analog devices in to the input ports: A1 and A2 of the ADC.

The potentiometer goes in the cutout of the case. The LDR and LCD will be mounted in the clock. The making of the clock is explained in the next step.

Clock

Clock_IRL.jpg

As you know in almost every official chess game there is a clock to time each player independently. My version of this clock involves a single LDR for both players to use as a termination of their turn. The LCD is added to display the IP of the server the website will run on. This step is not mandatory but my 3D model does include a cutout for it.

I used a Ultimaker 3S to print my model but any 3D printer should work fine. The .STL and .IPT of my model are to be found below. If you do not have a 3D printer to your disposal you can invent something on your own :)

Downloads

Chess Pieces

ChessPiece_IRL_1.jpg
ChessPiece_IRL_2.jpg

In order for the reed switches to be able to sense when a piece is picked up and placed we will need to put magnets in to the chess pieces. When using the same thickness of MDF as the top I calculated that 3 10mm x 1mm stacked on top per piece are the right magnetic strength. Drill a hole in the middle of each piece of 10mm diameter and about 5mm deep.

Put a little hot glue in the hole and carefully place 3 magnets in there. Turn it facing up and let it dry. Do this for everyone of the 32 pieces.

Putting It All Together

Board_IRL_1.jpg
Board_IRL_2.jpg

In this last part you will connect everything together. Use breadboards or soldering to your liking. Follow the schematic closely as a single mistake can ruin the entire project.

After all the electronics are sorted out, tape the acrylic chessboard on top with double sided tape. Place the magnetic chess pieces on the board. Now you should be ready to upload the code and start playing.

The code below will only work if you have a working Apache server and a MySQL database. I will not explain how to set these up in this Intractables because that would be far to complicated.

Link to GitHub code: https://github.com/howest-mct/2022-2023-projectone-HubeKnaepkens