Summary of Arduino Mega Chess on TFT display
This article details an Arduino-based chess program developed by an amateur to fulfill a childhood dream. The project utilizes an Arduino Mega 2560 and a touchscreen interface, employing the Negamax algorithm with iterative deepening and complex evaluation functions. Key features include full chess rules implementation, board rotation, FEN format loading, game saving to EEPROM, and adjustable thinking times ranging from 10 seconds to no limit. The author also notes plans to upgrade to a larger 3.5-inch display.
Parts used in the Arduino Chess Program:
- Arduino Mega 2560
- 2.8 inch touchscreen (initially)
- Passive buzzer
- EEPROM (for saving games)
- Serial port interface
- 3.5 inch MCUFRIEND touchscreen (updated version)
Story
After some my Arduino project remains unclaimed touchscreen, so I decided to realize my chidhood dream to create a chess program. After a couple of months it wins me, but it is not big deal because i do not have any chess rating, just amateur.
This project uses Arduino Mega 2560 because of lack of operative memory on Uno, 2.8 inch touchscreen, passive buzzer, and about 2000 lines of code.
Program uses Negamax algorithm, iterative deepening, some kind of killer heuristic, time control. No any bitboards or hashes for obvious reasons. Evaluate function is rather complicated, but not too much, anyway in except of material it calculates figures activity, king safity, pawn structure. Solve speed about 100-200 nodes per second.
Play is according to chess rules, including en passant, castling, pawn promotion. Draw is determined too. Algorithm also may give up if did no see any vay to escape checkmate.
Board is rotatable, step by drag and drop, can take step back. It is possible to arrange the initial position, or load from Serial port in FEN format. Chess game can be saved in EEPROM and downloaded later, or replayed in fast mode.
There is a checkmate search regime to solve chess problem.
Level of algorithm is given by choosing mean thinking time 10sec – 30sec -1min – 3min 10min – 30min – no limit. On 10 seconds regime play is adequate for me, but may be some probles in endspiel or with horizon effect. On 1min i don’t even try to win – may be it is just lack of assiduity.
If anybody like to repeat this project, and screen not be the same model, i see only difficulty to calibrate touchscreen, need to tune coordinate transformation coefficients. Later i will remake sketch on more common and big 3.5 inch touchscreen.
Sorry for poor decor – it is my first public project.
Thank you for attention.
Upd: 6 feb 2018:
As i promised, updated sketch to 3.5 inch MCUFRIEND touchscreen 320×480 pixels. Added new variant.
Read more: Arduino Mega Chess on TFT display
- Why was the Arduino Mega 2560 chosen for this project?
The Arduino Mega 2560 was selected because the Uno lacks sufficient operative memory. - What algorithm does the chess program use?
The program uses the Negamax algorithm combined with iterative deepening and killer heuristics. - Does the chess engine support standard chess rules like castling?
Yes, play follows all chess rules including en passant, castling, and pawn promotion. - How can a user adjust the difficulty level of the AI?
Difficulty is adjusted by choosing mean thinking time options ranging from 10 seconds to no limit. - Can the chessboard be rotated during gameplay?
Yes, the board is rotatable and supports step-by-step drag and drop movement. - Is it possible to load a game position using FEN format?
Yes, users can arrange initial positions or load them directly from the Serial port in FEN format. - How does the system handle saving and replaying games?
Games can be saved in EEPROM for later download or replayed in fast mode. - What are the main challenges if someone wants to replicate this project with a different screen?
The primary difficulty is calibrating the touchscreen and tuning coordinate transformation coefficients.

