Project: Clock One

Let‘s make a huge analogue and digital clock using a dot-matrix display.

Updated 18/03/2013

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.

Hardware

To make this happen you will need:

• 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!

Software

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:

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, 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.

The following two tabs change content below.

John Boxall

Person. Founder and original author for tronixstuff.com. VK3FJBX

Latest posts by John Boxall (see all)

1. I suggest to consider adding anti aliasing to the clock hands so they do not appear jaggy.

• Good call, however doing so is outside the scope of the hardware.
cheers
john

2. falldeaf says:

Great article! I hadn’t seen that DMD from Freetronics. I might have pick one up at that price! Pretty awesome that the logic is mostly built into the display.

• Thanks. Yes the design is simple and easy to use, Marc did a great job designing these and also kept the price low.
Have fun
John

3. I imagine it takes quite a lot of processing power to drive that display, once you factor in all of the multiplexing and everything else. So it’s a good thing it has an on-board controller really, otherwise your project would soon get itself bogged down in display driver stuff. It’s nice to be able to concentrate on your application!

I have a thing for clock projects as well, so I shall keep an eye on your blog. I notice you listed the 7-seg watch in your clock-project run down; I saw that a few weeks back and quite liked it, although I immediately thought ‘I can do better’, so I’m considering designing my own!

Bri

• Yes, the DMD is very well done. I’m seeing the designer today and will pass on your compliments.
That watch is very basic, anyone can do it 🙂 Have fun with it.
cheers
john

4. Kevin says:

Hi John,
I just received my DMD here in the U.K. I had it running in no time and I’m very pleased with it. Delivery was very quick too. Do you know if anyone has connected it to a GPS module?

• Glad to hear you like it, they’re a fun display. Haven’t seen a GPS connected one, however it shouldn’t be too hard. Perhaps ask on the Freetronics forum? http://forum.freetronics.com/
cheers
john

5. kiranvarma says:

John it was a neat explanation. can we generate the same clock by using other micro controller board with this DMD. anyway i enjoyed the entire project while reading. Your site has a lot of stuff to learn. Thank you John Boxall

• possibly – you could deconstruct the Arduino DMD library and see how it is addressed by the MCU.

6. lekmans says:

is the link’s sketch true? combilock1? or i just missed something?

7. lekmans says:

thx for update link 🙂

8. maybe a blue or different color of led for 5,10,20,25,35,40,50 and 55 minutes PLUS other colors for 0,15,30,and 45 will make the common user ( i do not say my wife because i hate canned food, and the sofa in the living room is very old )will make easier to read just at a glance to it.