Introduction: Chess Helper
Here I will show you my journey of making this light up chessboard. It can function as a way to help people learn chess moves as with the press of a button. Tiles will light up showing what moves to play next, this way it's easy to learn the basic rules of chess. Or if you want to remember a specific opening.
Supplies
Tinned Copper Wire
Arduino Nano.
Shift Register 74HC595 x1
LEDs x8
Transistor x8
Some wood :)
Plexiglass if you want.
a Button
Reed Sensor.
Chess pieces
Magnets.
Step 1: Leds and the Shift Register
What you'll need for this step are the LED's and the shift register. It's important to set this all up correctly before you start soldering to make sure everything is set up correctly.
The best way to set up the 595 Shift Register is to follow this guide
https://docs.arduino.cc/tutorials/communication/guide-to-shift-out
If you don't want to read all that you can follow this schematic down below. It should give you the same result. But it's handy to know how everything works in case something doesn't go right.
The following code will make the leds blink in order. It's like counting in binary
```
int clearPin = 5; //Arduino pin 5 connected to Pin 10, SRCLR(Clear/Reset) of 74HC595
int serialData = 6; //Arduino pin 6 connected to Pin 14, SER(serial input) of 74HC595
int shiftClock = 7; //Arduino pin 7 connected to Pin 11, SRCLK(shift clock) of 74HC595
int latchClock = 8; //Arduino pin 8 connected to Pin 12, RCLK(storage/latch clock) of 74HC595 ]
void setup() { //runs once at startup
//set pins to output so you can control the shift register
pinMode(clearPin, OUTPUT);
pinMode(shiftClock, OUTPUT);
pinMode(latchClock, OUTPUT);
pinMode(serialData, OUTPUT);
digitalWrite(clearPin, LOW); //Pin is active-low, this clears the shift register
digitalWrite(clearPin, HIGH); //Clear pin is inactive
}
void loop() { //runs and loops continuously
for (int shiftCount = 0; shiftCount < 256;shiftCount++) {
// count from 0 to 255 and display the number on the LEDs
digitalWrite(latchClock, LOW);
// take the latchClock low so
// the LEDs don't change while you're sending in bits:
shiftOut(serialData, shiftClock, MSBFIRST, shiftCount); // shift out the bits
digitalWrite(latchClock, HIGH); //take the latch pin high so the LEDs will light up
delay(500); // pause before next value
}
}
```
https://gyazo.com/35045f44624e480bc968531a3de88abb
anode cathode
Attachments
Step 2: Copper Wire and the Leds
After you're done testing if everything is setup correctly you'll want to expand the leds to the 64 that you need for the board. We start doing this by making an 8x8 grid. We connect all the Cathodes of 1 row to each other. Same for the Anodes. We will use the Tinned Copper wire for this step, as shown in the image provided.
To control them all individually you'll need 8 pins for the Anodes row of the LEDS. these will be connected to transistors as well as 1k Resistors. The code we'll use for this all will be listed in a later step.
You can keep everything the same on the breadboard if you want. You just need to connect the rows with the leds to where the leds were originally connected. There's maybe better ways to do this, but what I did is connect the ends of the copper wire to other wire so it's easier to connect.
Step 3: The Board and the Casing
For the casing I used wood and a laser cutter to get all the pieces I needed. I used black MDF for the casing and Plexiglass for the board.
If I would have to give any advice, make holes in the side and little things that stick out for the interlocking grid pieces to make assembly way easier. otherwise you're stuck gluing stuff together in a very unoptimized matter.
They way I did it is connecting the sides to each other, and once 2 pieces were glued together i turned the box upside down. Laid down the plexiglass board, put glue on the interlocking pieces and connected them to the wall like that. Unfortunately like that, it made it that the grid pieces didn't all connect to the wall which might cause issues in the future. For now everything seems to be okay.
Attachments
Step 4: Assembly and the Chess Pieces
Once the board is ready to go, you can try and assemble everything together. Time to put all the LED's you made into the casing, without the board for now.
The way i've done is just taping the wires with the leds to the interlocking part of the case. It's secure enough it just can cause some issues if the wires touch each other. So make sure that doesn't happen otherwise Some rows might not light up at all.
I don't glue the Board on the case because It's easier to secure the Reed Switch to the Arduino like that. The switches have a tendency to break so make sure to be careful with them.
For the pieces I 3d printed them. I did cut a hole out the bottom of the pieces in Blender.
https://www.thingiverse.com/thing:4168753
the hole was for the magnets that I would place in the pieces themselves. this way it's easier to trigger the reed switch.
Step 5: Coding
const byte IMAGES[][8] = { { B00111100, B01000010, B10100101, B10000001, B10100101, B10011001, B01000010, B00111100 }, { B00000000, B00111100, B01100110, B01100110, B01111110, B01100110, B01100110, B01100110 }, { B00000000, B01111100, B01100110, B01100110, B01111100, B01100110, B01100110, B01111100 }, { B00000000, B00111100, B01100110, B01100000, B01100000, B01100000, B01100110, B00111100 }, { B00000000, B01111100, B01100110, B01100110, B01100110, B01100110, B01100110, B01111100 }, { B00000000, B01111110, B01100000, B01100000, B01111100, B01100000, B01100000, B01111110 }, { B00000000, B01111110, B01100000, B01100000, B01111100, B01100000, B01100000, B01100000 }, { B00000000, B00111100, B01100110, B01100000, B01100000, B01101110, B01100110, B00111100 }, { B00000000, B01100110, B01100110, B01100110, B01111110, B01100110, B01100110, B01100110 }, { B00000000, B00111100, B00011000, B00011000, B00011000, B00011000, B00011000, B00111100 }, { B00000000, B00011110, B00001100, B00001100, B00001100, B01101100, B01101100, B00111000 }, { B00000000, B01100110, B01101100, B01111000, B01110000, B01111000, B01101100, B01100110 }, { B00000000, B01100000, B01100000, B01100000, B01100000, B01100000, B01100000, B01111110 }, { B00000000, B01100011, B01110111, B01111111, B01101011, B01100011, B01100011, B01100011 }, { B00000000, B01100011, B01110011, B01111011, B01101111, B01100111, B01100011, B01100011 }, { B00000000, B00111100, B01100110, B01100110, B01100110, B01100110, B01100110, B00111100 }, { B00000000, B01111100, B01100110, B01100110, B01100110, B01111100, B01100000, B01100000 }, { B00000000, B00111100, B01100110, B01100110, B01100110, B01101110, B00111100, B00000110 }, { B00000000, B01111100, B01100110, B01100110, B01111100, B01111000, B01101100, B01100110 }, { B00000000, B00111100, B01100110, B01100000, B00111100, B00000110, B01100110, B00111100 }, { B00000000, B01111110, B01011010, B00011000, B00011000, B00011000, B00011000, B00011000 }, { B00000000, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B00111110 }, { B00000000, B01100110, B01100110, B01100110, B01100110, B01100110, B00111100, B00011000 }, { B00000000, B01100011, B01100011, B01100011, B01101011, B01111111, B01110111, B01100011 }, { B00000000, B01100011, B01100011, B00110110, B00011100, B00110110, B01100011, B01100011 }, { B00000000, B01100110, B01100110, B01100110, B00111100, B00011000, B00011000, B00011000 }, { B00000000, B01111110, B00000110, B00001100, B00011000, B00110000, B01100000, B01111110 }, { B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000 }, { B00000000, B00000000, B00000000, B00111100, B00000110, B00111110, B01100110, B00111110 }, { B00000000, B01100000, B01100000, B01100000, B01111100, B01100110, B01100110, B01111100 }, { B00000000, B00000000, B00000000, B00111100, B01100110, B01100000, B01100110, B00111100 }, { B00000000, B00000110, B00000110, B00000110, B00111110, B01100110, B01100110, B00111110 }, { B00000000, B00000000, B00000000, B00111100, B01100110, B01111110, B01100000, B00111100 }, { B00000000, B00011100, B00110110, B00110000, B00110000, B01111100, B00110000, B00110000 }, { B00000000, B00000000, B00111110, B01100110, B01100110, B00111110, B00000110, B00111100 }, { B00000000, B01100000, B01100000, B01100000, B01111100, B01100110, B01100110, B01100110 }, { B00000000, B00000000, B00011000, B00000000, B00011000, B00011000, B00011000, B00111100 }, { B00000000, B00001100, B00000000, B00001100, B00001100, B01101100, B01101100, B00111000 }, { B00000000, B01100000, B01100000, B01100110, B01101100, B01111000, B01101100, B01100110 }, { B00000000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000 }, { B00000000, B00000000, B00000000, B01100011, B01110111, B01111111, B01101011, B01101011 }, { B00000000, B00000000, B00000000, B01111100, B01111110, B01100110, B01100110, B01100110 }, { B00000000, B00000000, B00000000, B00111100, B01100110, B01100110, B01100110, B00111100 }, { B00000000, B00000000, B01111100, B01100110, B01100110, B01111100, B01100000, B01100000 }, { B00000000, B00000000, B00111100, B01101100, B01101100, B00111100, B00001101, B00001111 }, { B00000000, B00000000, B00000000, B01111100, B01100110, B01100110, B01100000, B01100000 }, { B00000000, B00000000, B00000000, B00111110, B01000000, B00111100, B00000010, B01111100 }, { B00000000, B00000000, B00011000, B00011000, B01111110, B00011000, B00011000, B00011000 }, { B00000000, B00000000, B00000000, B01100110, B01100110, B01100110, B01100110, B00111110 }, { B00000000, B00000000, B00000000, B00000000, B01100110, B01100110, B00111100, B00011000 }, { B00000000, B00000000, B00000000, B01100011, B01101011, B01101011, B01101011, B00111110 }, { B00000000, B00000000, B00000000, B01100110, B00111100, B00011000, B00111100, B01100110 }, { B00000000, B00000000, B00000000, B01100110, B01100110, B00111110, B00000110, B00111100 }, { B00000000, B00000000, B00000000, B00111100, B00001100, B00011000, B00110000, B00111100 }};
const int IMAGES_LEN = sizeof(IMAGES) / 8;
uint8_t colPins[8] = { 2, 3, 4, 5, 6, 7, 8, 9};
int serialData = 10; //Arduino pin 10 connected to Pin 14, SER(serial input) of 74HC595
int shiftClock = 12; //Arduino pin 12 connected to Pin 11, SRCLK(shift clock) of 74HC595
int latchClock = 11; //Arduino pin 11 connected to Pin 12, RCLK(storage/latch clock) of 74HC595 ]
int reedPin = 13; //pin for reed switch.
void setup()
{
//runs once at startup
//set pins to output so you can control the shift register
//for loop for all the pins used in the Anodes
for (int i = 0; i < 8; i++) { pinMode(colPins[i], OUTPUT); }
pinMode(shiftClock, OUTPUT);
pinMode(latchClock, OUTPUT);
pinMode(serialData, OUTPUT);
pinMode(reedPin, INPUT_PULLUP);
bool triggered = false;
}
void Loop()
{
int proximity = digitalRead(reedPin);
// iterate each row
if(proximity == HIGH)
{
triggered = true;
}
//Only execute the following code if it's triggered by the reed switch.
if(triggered)
{
for (int i = 0; i < IMAGES_LEN; i++)
{
for (int j = 0; j < 100; j++)
{
int rowbits = 0x80;
for (int row = 0; row < 8; row++)
{
for (int k = 0; k < 8; k++)
digitalWrite(colPins[k], LOW); // Cleanup cols
writeData(rowbits); // prepare to write the row
for (int col = 0; col < 8; col++)
digitalWrite(colPins[7 - col], IMAGES[i][row] & 1 << col ? HIGH : LOW );
delay(1);
writeData(0);
rowbits >>= 1;
}
}
}
}
}
void writeData(byte data)
{
digitalWrite(latchClock, LOW);
shiftOut(serialData, shiftClock, LSBFIRST, data);
digitalWrite(latchClock, HIGH);
}
Attachments
Step 6: Helper Part
In Theory the helper part would only be adding button presses to the code to show the order of moves that you want to portray. You would need to find the correct byte data images from the above mentioned code to make the correct squares light up.
I hope this was insightful.