t r o n i x s t u f f

fun and learning with electronics

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:

For more information about the display used, please visit the Freetronics product pageDisclaimer – 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 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.

February 2, 2012 - Posted by | arduino, clocks, ds1307, DS3232, timing, tutorial | , , , , , , , , , , , , , , , , , , , ,

15 Comments »

  1. Love the clock project – nice one!

    Comment by brianjhoskins | February 2, 2012 | Reply

    • Thanks Brian, it was a lot of fun as well
      Cheers
      John

      Comment by John Boxall | February 2, 2012 | Reply

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

    Comment by Brett Viren | February 2, 2012 | Reply

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

      Comment by John Boxall | February 2, 2012 | Reply

  3. 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.

    Comment by falldeaf | February 3, 2012 | Reply

    • 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

      Comment by John Boxall | February 3, 2012 | Reply

  4. 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

    Comment by brianjhoskins | February 3, 2012 | Reply

    • 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

      Comment by John Boxall | February 3, 2012 | Reply

  5. 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?

    Comment by Kevin | June 17, 2012 | Reply

    • 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

      Comment by John Boxall | June 18, 2012 | Reply

  6. 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

    Comment by kiranvarma | July 2, 2012 | Reply

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

      Comment by John Boxall | July 4, 2012 | Reply

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

    Comment by lekmans | April 15, 2013 | Reply

    • No, the link was incorrect. It’s back to normal.

      Comment by John Boxall | April 15, 2013 | Reply

  8. thx for update link :)

    Comment by lekmans | April 15, 2013 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 3,838 other followers

%d bloggers like this: