Beginners start here

To build the chessboard  project assumes you have a good working knowledge of Python and can program a Raspberry PI so that it controls physical devices. If you cannot do that I recommend that you build your programming and device control skills gradually. I did.

When I started I had not programmed for thirty years and never done any electronics. The trick is to build up to it gradually. If you jump right in to  trying to build this chess project you will get lost very quickly.

The good news is that if you approach this step by step then building this project is within reach of anybody. There is a lot of it, but each part is relatively straight forward when studied alone.

Building the Raspberry Pi Noughts and Crosses project (NOX) will give you the skills you need!

It works the same way as the chess project with the same components, there is just less of it. 9 squares vs 64 and with a minimum of 4 solder points per square that’s 36 soldered connections for NOX compared with 256! for the chessboard.

“Why don’t you just give us your code?” I have been asked. Well:

First “hell is other peoples code” when you try to make my code work with the chess board you build it will inevitably not work. Trying to work out why without understanding the intricacies of the code is impossible. Worse still, I am an amateur coder. I try to make my code structured, but its still very messy. As I progress in building the new design I will try and program in a more consistent way and hope to publish the code.

Second: Where’s the fun in that? The whole point of this is to learn and be proud of what you have done. If you have the will, a bit of persistence and a very basic ability to code, you can do this. Oh yes and a lot of time and persistence. You will get it wrong more times than you get it right.

Third: There is more than one way to do this. There are lots of variations, using different components. I have described how I built MY chess board. YOU can use this as a base and do it differently. Again, the new build is more standardised so it will be easy tier to share code in the future.

But (there’s always a but), the great thing about this stuff on the internet is that we can all help each other by referencing what we have learned to give others a leg up. That’s what I try to do here. To build the chess set there are lots of puzzles to be solved and on this site I give you answers so that you can use my learning in you project. I also reference some of the really useful web sites from which I have learnt.

So now what?

If you don’t feel you have strong enough skills to build the chess board now, build up to it by learning each of the parts. This will also improve you Python programming skills.

“But I cannot program in Python”  Its very east to learn. I taught myself from this great book:

 

Obviously you should do your learning on a Raspberry Pi, so you also get to know your way around.

“But I don’t know enough about the Raspberry PI” So get

 

It includes a section on running Python and in particular on reading switches and turning on & off LEDS.

So now you know how to write Python code on a Raspberry Pi

Learn how to control more complicated devices.

The chess board is really just a grid of switches (reed) and a grid of lights, one laid upon the other.

When a switch changes state (open to close, or close to open) you need to track that and then send back a set of light flashes corresponding to the move. Occasionally you want to send messages to the user through the LCD screen and allow the user to give answers by pressing four extra buttons (e.g your Pawn has reached the 8th rank, what piece do you want it to become)

In the middle of all this you want to send messages to a chess engine (STOCKFISH) and get back a move.

 

The 3 x 3 matrix – Raspberry Pi Noughts and Crosses – Tic Tac Toe

As an exercise build a 3×3 matrix grid with both lights and Reed switches and writing a python program that lights an LED when a magnet is placed on the square and turns it off when it is lifted.

You can start by doing it a simple way using direct connections to the PI GPIO. You will need nine for the Reed switches, but try using only six by running the LEDs as a matrix. Remember to include the right resistors.

Now, work out how to add a 16×2 LCD to display the cell reference when its turned on.

If you really want to be clever you can add logic and turn this into a computer driven Tic Tac Toe (naughts and crosses) game with O and X pieces with magnets attached. You may need to add a few buttons for “new game” etc  The Python book above even has the logic you need.

If you can do this you can build the chessboard.

I2C microcontrollers.

You will understand that if we expand this 3×3 design to a chess board with 8×8 squares we will quickly run out of connections. Luckily there is a world of little microcontrollers built to do specialist tasks like monitor switches and turn on LEDs. They are in all the household gadgets like washing machines and they cost pence (or cents)

Phillips the electronics company came up with a neat way of talking to these, known as I2C.  All the devices can be connected to the same two I2C pins on your Raspberry PI. Each has a separate address so only reacts to messages with the right tag. You don’t need to worry about all the detail as libraries (pre-written lumps of code) exist to do this for you.

So the next step is to replace your direct connections in the 3×3 matrix with I2c devices and you have built the noughts and crosses project.

One MCP23017 can control up to 16 switches

The Adafruit 16×8 LED Matrix Driver Backpack – HT16K33 can control up to an 8 x 16 matrix/

See here for how to address the MCP23017

So if you can do all that you’ve virtually build the chess board. You just need to figure out how to put the bits together.

Elsewhere on this site you will find instructions for how to run the Stockfish chess engine from Python.

Good Luck. I would very much like to hear how you get on. Please post below.

3 Responses to Beginners start here

  1. Brian says:

    I would like to add to this list. I didn’t know python at all when I started customising picochess to work with my nonDGT board.

    I used this https://www.udemy.com/complete-python-bootcamp/
    Don’t be put off by the £195 price tag, they have constant offers, I paid £9.
    It;s a very good course.

  2. rob says:

    Hello.

    Thanks for this site. It’s great.
    I have a problem understanding this sentence “You will need nine for the Reed switches, but try using only six by running the LEDs as a matrix.”

    You mean connect 9 Led’s to 6 GPIO ? Or maybe use 6 redd switches ? I search we for some hint but I have no idea how to work with 9 LEDs but connect them all in 6 GPIO. Maybe I misunderstood something there ?

    • Max says:

      Yes, the sentence is not very clear. I am saying you need 9 wires for the Reed switches because in this design each needs to wired individually. This is because with multiple pieces on the board more than one switch might be activated. For the LEDS you could do the same thing and wire each of the 9 LEDs to its own pin. However LEDS are activated one at a time, so you could wire them as a matrix 3 horizontal & 3 vertical gives 6. There are a number of ways of wiring an N x N matrix and I suggest in this exercise that you “google” this challenge and see what you can do. However the section Raspberry PI Noughts and Crosses / Tic Tac Toe describes a way to do this in detail using the HT16K3 as a controller.
      In general if you are new to this, I would highly recommend building the NOX application. It will teach you most of what you need to know about the fundamentals and there is a lot less soldering.(and Unsoldering). I hope this helps. Max

Leave a Reply

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