The chessboard’s layout is labeled as in the following diagram.
This is also what the chess program we have outputs. Thus we need to perform two overall conversions to interface with the chess program. We need to convert the numerical move coordinates of the human’s chess move into a (letter, number) to (letter,number) coordinate. We also need to convert the computer’s letter, number coordinates to numerical coordinates for the XY table to perform its task.
The 8x8 “keypad” will be connected to PORTA and PORTB, so that it can be read by scanning the columns and reading the state of the row lines. Each lettered column line (“a” to “h”) will be connected to microcontroller output pins PA0 to PA7, and each horizontal numbered row will be connected to microcontroller input pins PB0 to PB7. It will be necessary to connect input pins PB0 to PB7 to pull-up resistors of value 10kΩ to 5V. The circuit schematic is shown below.
By successively driving a single column line low, and the other columns high, the microcontroller can then read the input ports to see whether any of them are low. A coincidence of a row and column line being low means that a human’s piece is occupying that particular square. If the input to the microcontroller is high when the column is driven low, this means there is no piece on that particular square. The scanning of the column lines will be done using a real-time interrupt.