Arduino UNO TFT LCD Touch Digital Chess Clock
a Christmas present to play face to face with your loved ones.
In this project we have developed a digital chess clock based on the Arduino UNO and an LCD screen to give to my young son. He has also collaborated in all the development and testing and now he thinks that C programming is easier than programming with Scratch.
This chess clock allows you to program all the most popular time control modes for the game of chess. From the simple time control, to the post-increments and pre-increments of time, as well as the bonuses for moves made in different stages of the game.
In this blog we describe the main time controls that are usually used in the game of chess, to later see the implementation in our chess clock program for Arduino.
What is a Chess Clock
A chess clock consists of two adjacent clocks with buttons to stop one clock while starting the other, so that the two clocks never run simultaneously.
Chess Time Controls
Different Time Limits Of A Chess Game
There are 5 main time limits of a chess game. Special names for the time limit tells us how fast the game is.
- Standard/Classical
- Sudden Death
- Rapid Chess
- Blitz Chess
- Bullet Chess
Standard/Classical
Used in tournaments often have a time limit of 40 moves in 2 hours, followed by 20 moves in 1 hour, and then 30 minutes of sudden death.
Sudden Death
We have to finish the game before our flag falls. This is also called a quickplay finish.
Rapid Chess
Both players start with 30 minutes for all their moves.
Blitz Chess
Normally means 5 minutes for the whole game. 3 minute blitz is also popular.
Bullet Chess
1 or 2 minutes is all you get.
Overtime Formats
Game time is split into two categories: the main time and overtime. To switch between the two requires players to trigger a series of events.
In chess, if the player reaches the fixed number of moves they can then trigger “bonus time,” which is in addition to the fixed time.
Chess Increments
An increment in chess is a small amount of time that is added to the clock after every move. It is usually set from 1 to 30 seconds.
There are five main types of Time Increments:
- Fischer or Cumulative add-back mode (also called FIDE, bonus, or progressive)
- Bronstein Delay or Non-cumulative add-back mode (also called Adagio)
- Simple Delay or Delay mode (also called Andante or US Delay)
- Time or Sudden death
The first three time controls implement some sort of delay clock, a small amount of time that is added for each move. The reason is that with a sudden-death time limit, all moves must be completed in the specified time, or the player loses. With a small delay added at each move, the player always has at least that much time to make a move. The three types of delay clocks differ in how the delay is implemented.
The last two time controls are somewhat different, as they do not rely on time delay.
Fischer or Cumulative add-back mode
A specified amount of time is added to the players main time each move, unless the player's main time ran out before they completed their move. For example, if the time control is 90+30 (ninety minutes of main time per player with a thirty-second increment each move), each player gets an additional thirty seconds added to their main time for each move, unless the player's main time ran out first. Under FIDE and US Chess rules, the increment is applied to the first move as well.
Bronstein delay or Non-cumulative add-back mode
This timing control adds time but unlike increment not always the maximum amount of time is added. If a player expends more than the specified delay, then the entire delay is added to the player's clock but if a player moves faster than the delay, only the exact amount of time expended by the player is added. As with increment, the delay time is applied to the first move under FIDE and US Chess rules.
Simple delay or US Delay
The clock waits for the delay period each move before the player's main time starts countdown down. For example, if the delay is ten seconds, the clock waits for ten seconds each move before the main time starts counting down. This is the current USA tournament standard.
Time or Sudden death
This is the simplest methodology. Each player is assigned a fixed amount of time for the whole game. If a player's main time expires, they lose the game.
Overview of our implementation
Time control reached
Hardware used
This program is compatible with all TFT LCD screens an Arduino models that the Adafruit TFTLCD Library supports.
For the examples shown, I am using:
You can also choose this one from Adafruit:
Software
You can download the complete Arduino Sketch form the github repository:
- Arduino UNO Chess Clock https://github.com/javagoza/ArduinoTFTChessClock
The sketch uses a library that we have also developed to display virtual seven-segment displays on a TFT screen. This library allows displaying various configurable displays without flickering on an Arduino UNO with a TFT LCD screen that generally has serious problems refreshing the data on the screen. /challenges-projects/project14/buildapresent/b/blog/posts/arduino-uno-chess-clock-_2d00_-tft-lcd-virtual-clock-display-library
- TFT LCD Virtual Segment Display for Arduino https://github.com/javagoza/TFTVirtualSegmentDisplay
Arduino Chess Clock Features
This Arduino TFT LCD Touch Clock has been designed to be used as game clock for Chess
The main features are:
- 5 different algorithms covering all popular timing standards
- Pre-move time increments modes
- Post-move time increment modes
- Up to 3 different stage definitions per game.
- Time mode without increments
- Cumulative add-back mode
- Non cumulative add-back mode
- Moves control for each stage.
- Auto selection for whites clock
- 24 preprogrammed options for quick and ease of use
- Move counter for all options
- Pause/Resume the game
Display and buttons
Settings
Preset modes
- 01 Time blitz 5 min
- 02 Time rapid 25 min
- 03 Time blitz 3 min
- 04 Time + guillotine 2 hrs f.b. 30 min
- 05 Time + guillotine 1 hrs f.b. 30 min
- 06 2 x Time + guillotine 2 hrs f.b. 1 hr f.b. 30 min
- 07 Time + repeating 2nd period 2 hours f.b. 1 hour (repeating)
- 08 Time + Bonus (“Fischer”) 25 min f.b. 5 min + 10 sec./move
- 09 Time + Bonus (“Fischer”) 2 hrs f.b. 15 min + 30 sec./move
- 10 2 x Time + Bonus (“Fischer”) 2 hrs, f.b. 1 hr f.b. 15 min + 30 sec./move
- 11 2 x Time + Bonus (“Fischer”) 1 hrs, f.b. 30 hr f.b. 15 min + 30 sec./move
- 12 Bonus (“Fischer”) blitz 3 min + 2 sec/move
- 13 Bonus (“Fischer”) rapid 25 min + 10 sec/move
- 14 Bonus (“Fischer”) slow 90 min + 30 sec/move
- 15 Bonus tournament 90 min f.b. 15 min (all + 30sec./move)
- 16 Bonus tournament 100 min f.b. 30 min (all + 30sec./move)
- 17 Delay (“Bronstein”) 5 min + 3 sec./move free
- 18 Delay (“Bronstein”) 25 min + 10 sec./move free
- 19 Delay (“Bronstein”) 1 hr 55 min 5 sec/move free
- 20 Delay (“US DELAY”) 5 min + 3 sec./move free
- 21 Delay (“US DELAY”) 25 min + 10 sec./move free
- 22 Delay (“US DELAY”) rapid 25 min + 10 sec/move
- 23 Delay (“US DELAY”) slow 90 min + 30 sec/move
-
24 Delay (“US DELAY”) tournament 90 min f.b. 15 min (all + 30sec./move)
How preset modes are defined
static const GameType games[24] PROGMEM = { { FISCHER, 0, 1, {{ 300, 0}, {0, 0}, {0, 0}}}, // 01 Time blitz 5 min { FISCHER, 0, 1, {{1500, 0}, {0, 0}, {0, 0}}}, // 02 Time rapid 25 min { FISCHER, 0, 1, {{ 180, 0}, {0, 0}, {0, 0}}}, // 03 Time blitz 3 min { FISCHER, 0, 2, {{7200,40}, {1800, 0}, {0, 0}}}, // 04 Time + guillotine 2 hrs f.b. 30 min { FISCHER, 0, 2, {{3600,40}, {1800, 0}, {0, 0}}}, // 05 Time + guillotine 1 hrs f.b. 30 min { FISCHER, 0, 3, {{7200, 40}, {3600, 20}, {1800, 0}}}, // 06 2 x Time + guillotine 2 hrs f.b. 1 hr f.b. 30 min { FISCHER, 0, 3, {{7200, 40}, {7200, 20}, {1800, 0}}}, // 07 Time + repeating 2nd period 2 hours f.b. 1 hour (repeating) { FISCHER, 10, 2, {{1500,40}, {300, 20}, {0, 0}}}, // 08 Time + Bonus (“Fischer”) 25 min f.b. 5 min + 10 sec./move { FISCHER, 30, 2, {{7200, 40}, {900, 0}, {0, 0}}}, // 09 Time + Bonus (“Fischer”) 2 hrs f.b. 15 min + 30 sec./move { FISCHER, 30, 3, {{7200, 40}, {7200, 20}, {900, 0}}}, // 10 2 x Time + Bonus (“Fischer”) 2 hrs, f.b. 1 hr f.b. 15 min + 30 sec./move { FISCHER, 30, 3, {{3600, 40}, {3600, 20}, {900, 0}}}, // 11 2 x Time + Bonus (“Fischer”) 1 hrs, f.b. 30 hr f.b. 15 min + 30 sec./move { FISCHER, 2, 1, {{180, 0}, {0, 0}, {0, 0}}}, // 12 Bonus (“Fischer”) blitz 3 min + 2 sec/move { FISCHER, 10, 1, {{1500, 0}, {0, 0}, {0, 0}}}, // 13 Bonus (“Fischer”) rapid 25 min + 10 sec/move { FISCHER, 30, 1, {{180, 0}, {0, 0}, {0, 0}}}, // 14 Bonus (“Fischer”) slow 90 min + 30 sec/move { FISCHER, 30, 2, {{5400, 40}, {900, 0}, {0, 0}}}, // 15 Bonus tournament 90 min f.b. 15 min (all + 30sec./move) { FISCHER, 30, 2, {{6000, 40}, {1800, 0}, {0, 0}}}, // 16 Bonus tournament 100 min f.b. 30 min (all + 30sec./move) { BRONSTEIN, 3, 1, {{300, 0}, {0, 0}, {0, 0}}}, // 17 Delay (“Bronstein”) 5 min + 3 sec./move free { BRONSTEIN, 10, 1, {{1500, 0}, {0, 0}, {0, 0}}}, // 18 Delay (“Bronstein”) 25 min + 10 sec./move free { BRONSTEIN, 5, 2, {{7200, 0}, {0, 0}, {0, 0}}}, // 19 Delay (“Bronstein”) 1 hr 55 min 5 sec/move free { DELAY, 3, 1, {{300, 0}, {0, 0}, {0, 0}}}, // 20 Delay (“US DELAY”) 5 min + 3 sec./move free { DELAY, 10, 1, {{1500, 0}, {0, 0}, {0, 0}}}, // 21 Delay (“US DELAY”) 25 min + 10 sec./move free { DELAY, 10, 1, {{1500, 0}, {0, 0}, {0, 0}}}, // 22 Delay (“US DELAY”) rapid 25 min + 10 sec/move { DELAY, 30, 1, {{180, 0}, {0, 0}, {0, 0}}}, // 23 Delay (“US DELAY”) slow 90 min + 30 sec/move { DELAY, 30, 2, {{5400, 40}, {900, 0}, {0, 0}}}, // 24 Delay (“US DELAY”) tournament 90 min f.b. 15 min (all + 30sec./move) };
enum IncrementType { DELAY = 0, // Delay the player's clock starts after the delay period BRONSTEIN, // Players receive the used portion of the increment at the end of each turn FISCHER // Players receive the full increment at the end of each turn, with increment 0 is BLIZT or GUILLOTINE }; struct StageType { long duration; int moves; }; struct GameType { IncrementType incrementType; uint16_t incrementSeconds; uint16_t stagesNumber; StageType stages[3]; };
Touchscreen selection of preset modes
Sample of the two clocks facing each other in the idle state to start the game. It has not yet been decided which clock will control White's time and which will control Black's.
The screen shows the chosen control mode (TIME, FISCHER, BRNSTEIN, US DELAY), the increment time to apply if it exists.
The different defined stages, the number of movements to complete in time and the time bonuses in the following stages.
Moves counter and color (White, Black) indicator
Pause/Resume
Reset game, new game, back to idle.
Github repositories
- Arduino UNO Chess Clock https://github.com/javagoza/ArduinoTFTChessClock
- TFT LCD Virtual Segment Display for Arduino https://github.com/javagoza/TFTVirtualSegmentDisplay
References
- What Is The Time Control For Chess Tournament: Rapid, Blitz, Bullet and Standard – Hercules Chess
- Time control - Wikipedia
- World Chess Federation handbook
- Time Control for Bullet, Blitz and Standard - Chess Stack Exchange
Project Blogs
Arduino UNO Digital Chess Clock
Arduino UNO Chess Clock TFT LCD Virtual Clock Display Library