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

# Arduino meets Las Vegas with the Freetronics DMD

Updated 05/11/2014

Time once more to have some fun, and this time by examining the Freetronics DMD “Dot Matrix Display” available from Tronixlabs. We will look at the setup and operation of the display. In a nutshell the DMD comprises of a board measuring approximately 320mm across by 160mm which contains 16 rows of 32 high-intensity red LEDs. For example, in the off state:

Connection of the DMD to your Arduino-compatible board is quite simple. Included with each DMD is a 2×8 IDC cable of around 220mm in length, and a PCB to allow direct connection to the Arduino digital pins D6~13:

Finally the cable connects to the left-hand socket on the rear of the DMD:

You can also daisy-chain more than one display, so a matching output socket is also provided. Finally, an external power supply is recommended in order to drive the LEDs as maximum brightness – 5V at ~4 A per DMD. This is connected to a separate terminal on the rear of the board:

Do not connect these terminals to the 5V/GND of your Arduino board!

A power cable with lugs is also included so you can daisy chain the high-intensity power feeds as well. When using this method, ensure your power supply can deliver 5V at 4A  for each DMD used – so for two DMDs, you will need 8A, etc. For testing (and our demonstration) purposes you can simply connect the DMD to your Arduino via the IDC cable, however the LEDs will not light at their full potential.

Using the display with your Arduino sketches is quite simple. There is an enthusiastic group of people working on the library which you will need, and you can download it from and follow the progress at the DMD Github page and forks. Furthermore, there is always the Freetronics forum for help, advice and conversation. Finally you will also need the TimerOne library – available from here.

However for now let’s run through the use of the DMD and get things moving. Starting with scrolling text – download the demonstration sketch from here. All the code in the sketch outside of void loop() is necessary. Replace the text within the quotes with what you would like to scroll across the display, and enter the number of characters (including spaces) in the next parameter. Finally, if you have more than one display change the 1 to your number of displays in #define DISPLAYS_ACROSS 1.

Here is a quick video of our example sketch:

Now for some more static display functions – starting with clearing the display. You can use

to turn off all the pixels, or

to turn on all the pixels.

Note: turning on more pixels at once increases the current draw. Always keep this in mind and measure with an ammeter if unsure.

Next some text. First you need to choose the font, at the time of writing there were two to choose from. Use

for a smaller font or

for a larger font. To position a single character on the DMD, use:

which will display the character ‘x’ at location x,y (in pixels – starting from zero). For example, using

results with:

Note if you have the pixels on ‘behind’ the character, the unused pixels in the character are not ‘transparent’. For example:

However if you change the last parameter to GRAPHICS_NOR, the unused pixels will become ‘transparent’. For example:

You can also use the parameter GRAPHICS_OR to overlay a character on the display. This is done with the blinking colon in the example sketch provided with the library.

Next, to draw a string (group of characters). This is simple, just select your font type and then use (for example):

Again, the 5 is a parameter for the length of the string to display. This results in the following:

Next up we look at the graphic commands. To control an individual pixel, use

And changing the 1 to a 0 turns off the pixel. To draw a circle with the centre at x,y and a radius r, use

To draw a line from x1, y2 to x2, y2, use:

To draw a rectangle from x1, y2 to x2, y, use:

And to draw a filled rectangle use:

Now let’s put those functions to work. You can download the demonstration sketch from here, and watch the following results:

Update – the DMD is also available in other colours, such as white:

So there you have it, an inexpensive and easy to use display board with all sorts of applications. Although the demonstrations contained within this article were rather simple, you now have the knowledge to apply your imagination to the DMD and display what you like. For more information, check out the entire DMD range at Tronixlabs. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

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, or join our forum – dedicated to the projects and related items on this website.