Project: Clock One
Let‘s make a huge analogue and digital clock using a dot-matrix display.
For some strange reason I have a fascination with various types of electronic clocks (which explains this article). Therefore this project will be the start of an irregular series of clock projects whose goal will be easy to follow and produce interesting results. Our “Clock One” will use a Freetronics Dot Matrix Display board as reviewed previously. Here is an example of an operating Clock One:
As you can see, on the left half of the board we have a representation of an analogue clock. Considering we only have sixteen rows of sixteen LEDs, it isn’t too bad at all. The seconds are illuminated by sixty pixels that circumnavigate the square clock throughout the minute. On the right we display the first two letters of the day of the week, and below this the date. In the example image above, the time is 6:08. We omitted the month – if you don’t know what month it is you have larger problems.
To make this happen you will need:
- A Freetronics Dot Matrix Display board;
- If you want the run the display at full brightness (ouch!) you will need a 5V 2.8A power supply – however our example is running without the external supply and is pretty strong
- An Arduino board of some sort, an Uno or Eleven is a good start
- A Maxim DS1307 real-time clock IC circuit. How to build this is explained here. If you have a Freetronics board, you can add this circuit directly onto the board!
Planning the clock was quite simple. As we can only draw lines, individual pixels, and strings of text or individual characters, some planning was required in order to control the display board. A simple method is to use some graph paper and note down where you want things and the coordinates for each pixel of interest, for example:
Using the plan you can determine where you want things to go, and then the coordinates for pixels, positions of lines and so on. The operation for this clock is as follows:
- display the day of week
- display the date
- draw the hour hand
- draw the minute hand
- then turn on each pixel representing the seconds
- after the 59th second, turn off the pixels on the left-hand side of the display (to wipe the clock face)
There isn’t a need to wipe the right hand side of the display, as the characters have a ‘clear’ background which takes care of this when updated. At this point you can download the Arduino sketch from here. Note that the sketch was written to get the job done and ease of reading and therefore not what some people would call efficient. Some assumed knowledge is required – to catch up on the use of the display, see here; and for DS1307 real-time clock ICs, see here.
The sketch uses the popular method of reading and writing time data to the DS1307 using functions setDateDs1307 and getDateDs1307. You can initally set the time within void setup() – after uploading the sketch, comment out the setDateDs1307 line and upload the sketch again, otherwise every time the board resets or has a power outage the time will revert to the originally-set point.
Each display function is individual and uses many switch…case statements to determine which line or pixel to draw. This was done again to draw the characters on the right due to function limitations with the display library. But again it works, so I’m satisfied with it. You are always free to download and modify the code yourself. Moving forward, here is a short video clip of the Clock One in action:
For more information about the display used, please visit the Freetronics product page. Disclaimer – The display module used in this article is a promotional consideration made available by Freetronics.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.