BUILD IT YOURSELF
By Theron Wierenga
An Electronic Chessboard
Using RGB LED Strips and
Last month's article
finished with the
Aflow chart of the Teensy 3.1 loop() function is hown in Figure 1. The mainLoop() function contains the majority of the functionality of
the chessboard program; a simplified flow chart of it
appears in Figure 2.
The mainLoop() function processes three possible
legal moves for each turn:
and its construction.
1. A piece moves to a legal empty space.
Also presented was
2. A piece is picked up, but is just returned to its
how the software
3. A piece captures an opponent’s piece.
knows a piece has
been moved and
The mainLoop() function starts by simply looking for
a piece that has been removed from the board. Here is
a code fragment:
what piece it was.
Now on to the
software needed to
take two players
int total1 = 0, total2 = 0, total3 = 0;
// For different reads of total number of pieces
// on the board
total1 = readHall(piecesTemp1);
// Read the Hall Effect sensors
}while (total1 == bdCount);
// Wait for a change
through a game of
The readHall() function returns the total number of
pieces found on the board, which is compared to the
current board count bdCount. Next, the temporary
array piece Temp1 is compared with piecesCurrent
■ FIGURE 1. Flow chart
of the Teensy 3.1 loop().
18 February 2017