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:

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

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

This page (Code & Wiring) was last updated on Oct 14, 2012.

Text editor powered by tinymce.