Checkers Renew

by XanderWaeghe in Circuits > Raspberry Pi

494 Views, 0 Favorites, 0 Comments

Checkers Renew

Homepage.png

Hey there!

For my school project at MCT Howest Kortrijk I made a digital checkerboard. In this project all kinds of sensors and actuators are used. In this tutorial I will show you step by step how I made this project in 4 weeks.

My GitHub: https://github.com/WaegheXander

My Personal GitHub: https://github.com/XWippie


How to make an old game like checkers better/modern?

Solution:

Checkers but digital i.e. all steps, time, etc... will be recorded and forwarded to a database, also it will be available on a web server what is happening live on the board.


Project Results
Checkers but modernized. Checkers will remain the same on an 8x8 board. Only the color white will be playable. There is 1 button in the middle on the side with 1 led strip the program itself will randomly determine who starts. The one who starts will have his LEDs lit, once that player has finished his move he will have to press the button so that the other one can play. If the players make a wrong move a buzzer sound will play, this will also happen when the game is over and the game starts. The score will also be visible on the led strip. Starting the game will be done with a RFID card. All data from the board such as time, score, where each disc is, who is playing will be sent to a database. At the end of the match there will be small statistics such as: score, who made his move faster, etc... On the webserver this will all be visible, during the game there will be a live view of the game board and score.

Why this project?

I used to play a lot of checkers with my grandmother, but after a long time it becomes little boring and I thought to make something special with it something new. Therefore this project

Bill Of Materials (BOM)

- 1x | RFID sensor module | is used to know which players are playing at that time

link: https://www.amazon.com/gp/product/B07VLDSYRW/ref=e...

- 32x | Reed Contact Normally Open | is used to know where there are pawns

link: https://www.amazon.com/gp/product/B07YFBQ4HS/ref=o...

- 1x | LED Strip WS2811 300 LEDs | this is split into 2 ledstrip to indicate the score per player

link: https://www.amazon.com/ALITOVE-Addressable-Program...

- 1x | Passive Electronic Buzzer | is used to indicate whether something went well or badly

link: https://www.amazon.com/gp/product/B01GJLE5BS/ref=o...

- 1x | Raspberry Pi 4 model B - 4GB | is the most important component of all. This is where all the calculations are made.

link: https://www.raspberrystore.nl/PrestaShop/en/raspbe...

- 1x | LCD Display 16 char | on the lcd comes the lan and wan ip.

link: https://amazon.com/gp/product/B07S7PJYM6/ref=ewc_p...

- 1x | PCF8574 8bit I2C extender | is used to control the lcd

link: https://www.amazon.nl/partij-PCF8574P-PCF8574-DIP-...

- 2x | MCP23018 16 bit I2c extender | is used to read out the 32 reed contacts

link: https://www.gotron.be/ic-expander-16-bit-i-o-port-...

- 1x | TTP223B Digitale Capacitieve touch sensor | is used to know to which person it is to make a move

link: https://www.amazon.nl/AZDelivery-Capacitieve-Aanra...

- 1x | casing

Total price: € 188,35

Draw Up Diagrams

Picture1.png
breadboard.png
schema.png

Before we can connect electronics we need to know how.

For my schematic I used Fritzing, it's a program you can install which allows you to create a schematic really easy in different kinds of views.


Download Fritzing: http://fritzing.org/

To start you create a block diagram to visualize the basics of what you will need. After the block diagram is made we can start to make an electronic diagram, from this we can make the BOM (bill of materials). The BOM can be ordered immediately so that the components will arrive on time. From the electronic diagram we can then make the breadboard diagram that shows how and where everything must be connected. (see pictures)

So make sure you connect everything in the right way! In my case the colors of the wires are not the same like on the schematic.

Switching of the Components

20220531_122413.jpg
20220531_122406.jpg

Switching of the components

Switching the components I did in several phases:

- Phase 1: Switching the 32 sensors, these are with a pull up resistor and in the code the ouput is inverted to get a logical output. If I don't do this, a 1 will come out if nothing is lit and a 0 if something is lit.

- Phase 2: Connecting the rfid via MOSI and MISO we use a library in the code to read it out correctly.

- Phase 3: Connecting the buzzer, this is directly connected to the 3.3Volt to generate a loud beep.

- Phase 4: Connecting the led strips, this is also controlled by a library.

Making the Casing

20220603_113303.jpg
20220605_170204.jpg
20220606_181417.jpg

For my housing I used illustrator to design the housing

To make a casing, I chose to laser-cut. I went for 3mm mdf this is necessary to not block the magnetic field. Also because this is easy to work with and easy to put in one. Of course the price is also a bit higher than other diy, but it is a bit better to work with. Ik heb het laten lasercutten in het IDC in howest Kortijk.

putting together:

While gluing it was there should be enough weights on it for a good solid settlement. every time you glue something it should dry for 24 hours.

Creating Database

Schermafbeelding 2022-05-25 091442.png

Behind this there is a lot of thinking work. I create a table for history, here all the steps are stored per game pet player and also keep track of when. Another table is game here every game is recorded per 2 players and the 2 scores are also recorded the start date. Of course there is also a table player, here I keep track of who can play (name) linked to a rfid id. The last table is separate from the rest, this is because this is live data which box is which pawn.

To convert the schema to a database a forward engineer is done, this means from a schema to a whole database.

See picture for the schema

Database dump file:

https://github.com/howest-mct/2021-2022-projectone...

Rapsberry Pi Configuration

SD Card configuration First, you need a min 16GB SD Card where you can put your image on and a program to upload a start image to the SD card.

Software: https://sourceforge.net/projects/win32diskimager/...

Start image: https://sourceforge.net/projects/win32diskimager/...

So once these are downloaded:

- Put your SD card in your computer.

- Open up Win32 which you just downloaded.

- Select the Raspbian image file which you also just downloaded.

- Click on 'write' to the location of your SD card.

This may take some time, depending on your hardware. Once this is done, we are ready to make some final adjustments before putting the image into our RPi.

- Go to your SD card's directory, search for the file named 'cmdline.txt' and open it.

- Now add 'ip=169.254.10.1' on the same one line.

- Save the file.

- Create a file named 'ssh' without extension or content.

Now you can SAFELY eject the SD card from your computer and put it into the Raspberry Pi WITHOUT power. Once the SD card is into the RPI, connect a LAN cable from your computer to the RPi LAN port, once this is connected you can connect the power to the RPi.

Now we want to control our Raspberry Pi, this is done through Putty.

Putty software: https://sourceforge.net/projects/win32diskimager/...

Once downloaded, open up Putty and insert the IP '192.168.168.169' and Port '22' and connection type: SSH. Now we can finally open our command line interface and login with the starter login information -> User: student & Password: W8w00rd.

Raspi-config

'sudo raspi-config'

What is really important for this project is the interfacing section, we have to enable a lot of different interfaces, enable all the following interfaces:

- I2CSerial

Now that we're done with raspi-config, let's try and make a connection with internet.

In the Iso file provided, many configurations have already been done, so this was only necessary.

Writing Backend

So now the setup is done, we can finally begin writing our backend program!

I used Visual studio code for my whole backend, you just need to make sure your Visual studio code project is connected to your Raspberry Pi, this means your Deployment path is set up in your settings and you installed all the packages we need, should be already installed. I used my own classes and these are also all included in my GitHub. In my backend file I used threading classes, so everything can run at the same time and it won't interrupt each other, I also used interups to make buttons work better. And at the bottom you got all the routes so we can easily get data in our frontend.

Frontend

FPY6GG2L42QZ194.png
Bord – 1.png
Bord.png
Homepage – 1.png

Now that the backend is done, we can start writing the full front-end.

HTML & CSS was done pretty easy, tried working mobile first as much as possible. You can design your dashboard in any way you want to, i'll just leave my code and design here, you can do whatever you like! And Javascript was really hard to get everython to work, worked with a few GET's from my backend routes, tons of event listeners and some socketio structures.