Overview & Parts

While watching Tron for the umpteenth time, I started thinking about how data could be displayed in abstract, but still readable, ways.  The OLED display, with its crispness, seemed like a good fit for what I had in mind.  After considering a few different options, I settled on building a stylized clock display.

You will need:
The blocks are drawn so that, from outside to inside, each ring represents hours, minutes, and seconds.  The time is read with 0 at the top left corner.  The current hour and minute are indicated by the empty block in each ring.  The current second is drawn as a solid block (this ends up looking like a square moving around the inside ring).  In the above picture, the time can be read as 8:23 and about 38 seconds.

Code & Wiring

The overall circuit is set up by following the wiring in the tutorial on the monochrome 128×64 OLED and plugging the RTC breakout board directly into the Arduino as shown in the DS1307 tutorial.

The main sketch file handles reading the current time and drawing the rectangles.  A second file contains the coordinates for each rectangle.  The rectangles are broken up into three arrays - hour_rects, minute_rects, & second_rects and ordered by the appropriate time value.  The advantage of this approach is that modifying the design of the clock is as easy as adjusting the values in the appropriate array entry.  The biggest downside was the increase in memory usage; I ended up keeping the arrays in program memory by declaring the arrays with the prog_uint8_t type and PROGMEM attribute:

Download: file
prog_uint8_t hour_rects[12][4] PROGMEM = { ... };
Also, reading from the arrays required the use of an appropriate function:
Download: file
pgm_read_byte_near(&rectangles[i][0]);

Downloads

This guide was first published on Dec 17, 2012. It was last updated on Dec 17, 2012.