Reverse chess clock...

Hi, I am pretty new to arduino programming and i am looking for a starting code i could use to create what i call a "reverse" chess clock, basically a two timers clock that measure how long each player took to play their turns. I plan to use two input buttons and a lcd shield display. Anybody can tell me where i should start?

Thank you.

Anybody can tell me where i should start?

Certainly something a Arduino project could perform. The best way would be for you to start learning how to write Arduino sketch programs on your own.

This would not be a hard program to write once you learn the fundementals of the Arduino C/C++ programming language.


well i have been working on this simple project for over a month now... and the result are kind of deceiving :'(. This is why i was asking if anybody had a code i could get started with... I think i have a lot to learn about variable attribution and program structure. Thank you lefty for your kind words.

Based on your description, and my knowledge of chess clocks (love chess, hate clocks), I cannot see the 'reverse' aspect of this clock. It seems like a normal chess clock, in that it has two timers that clock the time taken by each player.

... Correct me if I'm wrong

Typically, once one player has moved, the other player's turn starts. They have two minutes to complete a move. The clock, then, shows the time remaining, rather than the time taken.

A good place to start would be a clock.

Here is a little code that I made to start any timing project I do-

// Set up Timer2 for an interrupt every 10 usec.
// Toggle the LED and print the value of millis()
// after every 100,000 interrupts.  (Every second
// or so.)
// The Interrupt Service routine simply increments a
// global variable.
// When the variable reaches 100,000, the loop() resets
// the variable, toggles the LED state, and performs a
// printout.
// LDU

enum TimerState {

 * Class for keeping time
class TimeDateKeeper {
  char seconds;
  char minutes;
  char hours;
  TimeDateKeeper(char _sec_in, char _min_in, char _hour_in);
  int Update_seconds();
  int Update_minutes();
  int Update_hours();

//constructor for class
TimeDateKeeper::TimeDateKeeper(char _sec_in, char _min_in, char _hour_in) {
  seconds = _sec_in;
  minutes = _min_in;
  hours = _hour_in;

//if resetting, return increment error. Otherwise increment seconds
int TimeDateKeeper::Update_seconds() {
  if(seconds >= 59) {
    seconds = 0;
    return 0;
  return 1;

//if resetting, return increment error. Otherwise increment minutes
int TimeDateKeeper::Update_minutes() {
  if(minutes >= 59) {
    minutes = 0;
    return 0;
  return 1;

//if resetting, return increment error. Otherwise increment hours
int TimeDateKeeper::Update_hours() {
  if(hours >= 23) {
    hours = 0;
    return 0;
  return 1;

void setup()


unsigned long int_count = 0;
unsigned long max_count = 100000;
TimeDateKeeper myTimer(0,0,0);
TimerState State = No_Update;

void loop()

  switch (State) {
  case No_Update: 
      if (int_count >= max_count) {
        int_count = 0;
        State = Update_seconds;
  case Update_seconds: 
      //if seconds reset to 0, update minutes. Else, return to no update status
      !myTimer.Update_seconds() ? State = Update_minutes : State = No_Update;
  case Update_minutes: 
      //if minutes reset to 0, update hours. Else, return to no update status
      !myTimer.Update_minutes() ? State = Update_hours : State = No_Update;    
  case Update_hours: 
      //Update hours and return to "no update" status.
      State = No_Update;

      //for future development...
      //!myTimer.Update_hours() ? State = Update_date : State = No_Update;    


      //if error state is found, return to "no update" status
      State = No_Update;


//This is where the user chooses how to display 
//the clock time...
void DisplayTime() {
  Serial.print(myTimer.hours, DEC);
  Serial.print(myTimer.minutes, DEC);
  Serial.println(myTimer.seconds, DEC);
void SetupTimerISR() {
  // Disable interrupts while setting registers

  // Reset control registers
  TCCR2A = 0;
  TCCR2B = 0;

  // Clear Timer on Compare Match (CTC) Mode
  TCCR2A |= (1 << WGM21);

  // Prescaler x1
  TCCR2B |= (1 << CS20);

  // Interrupt every 160/16e6 = 10 usec
  OCR2A = 159;

  // Use system clock for Timer/Counter2
  ASSR &= ~(1 << AS2);

  // Reset Timer/Counter2 Interrupt Mask Register
  TIMSK2 = 0;

  // Enable Output Compare Match A Interrupt
  TIMSK2 |= (1 << OCIE2A);

  // Enable interrupts once registers have been update

// This ISR is run when Timer/Counter2 reaches OCR2A

You can create a new clock every time the button is pushed.

Thanks a million!

You save what was left of my self-esteem by avoiding me to post what code I had already written. ;D

I will start to work on it as soon as I'm back from work!