Introduction: Arduino Chessclock

Picture of Arduino Chessclock

I could not find instructions on a good Arduino chess clock so instead I built my own which I will describe here.



Step 1: Parts List

Picture of Parts List

here are the things you will need:

Arduino nano (or any arduino UNO type will do)
soldering iron
solder
PCB board or vero board
2 dual AA battery holders
3 X 10k OHM resistors
fuse holder
2 X earth pins from 2 UK plugs
2 X 4 digit 7-segment displays
buzzer
1 toggle switch
1 button small (press to make type)
USB 1 cable (or whatever fits in your Arduino)
mics fittings and nuts bolts. For this I bid and won a meccano set on ebay and used what I found
Casing (optional)
breadboard and jumper cables (optional but recommended to prototype it first)
time, plenty of time!

I attached an image but this was from my spares after my build so some components are missing as noted.

Step 2: Prototyping

Picture of Prototyping

The whole project can be split into these parts:

1. getting the circuit right
2. the program
3. the physical layout

This step is optional since I will give you the circuit diagram but I do highly recommend that you give it a go in a breadboard first as it will confirm (or not) that you have all the parts that you need and enable you to think about the physical layout of all the pieces for a housing or base. 

I have attached here a picture of my prototype in a breadboard and also a circuit diagram. Some notes on the circuit:

1. In the top left of the circuit diagram shows the pin on the display that is connected to the segment (Cathodes) or the digit (Anodes).
2. You will note that for each display the segments (Cathodes) are connected to the respective segment on the other display. This is because the display is multiplexed to display the correct digits
3. the reset switch and the rocker is wired up with pull down resistors so as to keep the input LOW when the respective button is not depressed. see http://www.arduino.cc/en/tutorial/button for more details on this.
4.The power circuit is completely separate but simple. It is 4 AA batteries in serial with a switch are soldered into the red and black leads of to a cut USB cable. The USB cable then goes into the arduino. 

Step 3: The Program

Picture of The Program

Once you have it on a breadboard then you need to write the controller. Fortunately for you I have attached my code here but I would encourage you to have a go or tweak this code. If you are going to write it from scratch you first work out which pins to set to what to make all the 10 digits, I have then coded an additional 2 patterns, one for when time is run out and one to represent 10 in a single digit (see image). 

The next step is to multiplex the digits so you can potentially display a different number or pattern on each of the 8 digits. I tweaked the speed of the multiplexing until it looked right, too fast and the numbers merge between neighboring digits and too slow and the naked eye can notice the multiplexing.

The next step is to count the numbers down as 2 sets of 4 numbers representing 2 countdowns. I chose to use the first digit for minutes, the next 2 for seconds and the last one for tenths of seconds but you could chose to have 2 for minutes and 2 for seconds.

The countdown can be calibrated with a simple for loop that does nothing so that a tick of a 'second' on the display is actually a real second. I got mine pretty close but I figured that it doesn't matter too much for an informal game of chess if each play has the same number of units. I guess you might want to make it more accurate if you want to use your chess clock for a tournament or even to time an egg!

The clock loads into reset mode when turned on. Then it waits for the rockers to be hit on either side and counts down from the (default) 5 mins. The code listens to the reset button when the rocker is balanced.  if it is hit then the clock goes into reset mode again. At this point the reset button can be used to cycle through the minutes desired for each play from 1 to 10. when the desired time is displayed the rocker can be hit again to start the clock.

lastly you need it to do something to indicate that the time has run out in my case it displays all dashes (-) and plays a series of beeps, then it shows one side as 0000 (the loser) and the other side as whatever time was unused by the winner.

Step 4: Physical Build

Picture of Physical Build

The next phase is the physical build. 

Rocker switch

The first piece is to build the rocker switch. This switch must close one of two connections but never both. Also it must be able to balance in the middle where it closes neither connection. This pauses the clock. Here I used a small length of wood and screwed a UK ground pin to either end. Then a pivot is built in the middle to raise the rocker off the board. Again I used my ebay meccano extensively for this bit. When the rocker is mounted onto the board the ground pins need to go into the fuse holder clips to close the connection. To make this have a smooth feel I filed down the edges of the ground pins so the go into the fuse holder move easily (see image).

Layout

I first mounted the empty PCBs onto a perspex sheet with a gap for the pivot of the rocker switch. Then I took it back off and soldered the components and wire in with the same gap. If you do not do this you may find it difficult to bolt the resulting boards back onto the perspex of base. 
Draw the layout out on paper first and bear in mind:
- how high the 'up' side of each rocker will be for the housing
- some components like the battery holders and Arduino USB port need to be accessible after completion
 - If switches are to be mounted on a lid of the housing then connect their wires with connectors so the lid can be completely removed. (mine only has a hinge but I did this anyway)
 - I tilted the 7-segment displays by extending the pins on one side with fuse wire which allows that side to sit higher out of the board

Housing

I had planned to build a custom housing but in the end I did not have enough time and the perspex is difficult to cut so I bought a box that was similar size to what I needed and modified it a bit. I think it is good to have transparent casing so the workings can be seen but make sure that the batteries and the USB port remain available for program tweaks.

That's it have fun and good luck! 

Step 5: Other Options...

Possible enhancements or options:

- play a different sequence of beeps depending on which side wins
- play a tune on completion I believe this to be possible with the analogue pins and an appropriate buzzer.
- different official chess timing patterns (for example add time for each move played)
 - use the 7 segment to be 2 digits for minutes and 2 for seconds


Comments

sanz3 (author)2015-06-12

arduino chessclock

Hello friend

I tried to do with push button in protoboard but

this scheme has not worked

You'd know that change to make it work???

the push button I use similar than this

http://www.joystick-arcade.com/481-large_default/p...

COULD YOUD SEND ME A PROTEUS ARCHIVE?

THANKS

REGARDS

battulgab (author)2015-03-15

I have to run it on preteus, but i can't, help me pls

telonics (author)2015-03-04

I had not heard about proteus but i just googled it and it looks pretty cool so i will see if i can create one..

battulgab (author)telonics2015-03-14

I have to run it on preteus

battulgab (author)2015-03-04

proteus project picture pls give me!!

telonics (author)2013-12-15

hi Emmanuel,

Great that you want to give it a go. ok if you want to make the display to HH:MM (hours:minutes) then you need to do two things, firstly change this code which makes the digits increment when the higher ones roll over from:

if (d==-1)
{d=9;c--;}
if (c==-1)
{c=9;b--;}
if (b==-1)
{b=5;a--;}
if (a==-1)
{ ...

AND

if (h==-1)
{h=9;g--;}
if (g==-1)
{g=5;f--;}
if (f==-1)
{f=9;e--;}
if (e==-1)
{

TO:


if (d==-1)
{d=9;c--;}
if (c==-1)
{c=5;b--;}
if (b==-1)
{b=9;a--;}
if (a==-1)
{ ...


if (h==-1)
{h=9;g--;}
if (g==-1)
{g=5;f--;}
if (f==-1)
{f=9;e--;}
if (e==-1)
{
then you need to slow the timer down so that the digit on the far right increments at one change per second, do this change the following line and increase 6 until the last number ticks once per second exactly (compare to a real clock). If it needs further find tuning add a sleep command which is more fine of a delay

shownumbers (numToShow ,6,false);

If this is not what you need then sorry I did not understand correctly but you can ask again, Good luck!

Emmanuel_PR (author)2013-12-14

Thank you so much for sharing your proyect, I really interested to do it but I have a question, I'm a beginner programmer, I checked the program code but I don't know how can I change the time, could you tell me what I need to do to change the time? I don't want see only minutes on the display, I want to have an option for see hours using the same display, for example if I press the reset button one time would be 10 minutes but If I press the reset button once again it would be 2 hours, sorry for my english I'm Mexican, greetings!

Emmanuel_PR (author)2013-12-14

Thank you so much for sharing your proyect, I really interested to do it but I have a question, I'm a beginner programmer, I checked the program code but I don't know how can I change the time, could you tell me what I need to do to change the time? I don't want see only minutes on the display, I want to have an option for see hours using the same display, for example if I press the reset button one time would be 10 minutes but If I press the reset button once again it would be 2 hours, sorry for my english I'm Mexican, greetings!

Fishsticks888888 (author)2013-10-06

cool:)

About This Instructable

12,063views

18favorites

More by telonics:Electronic Paper Rock Scissors GameBlackjack Basic Strategy Calculator ring wing paper plane
Add instructable to: