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:

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

This page (Code & Wiring) was last updated on Apr 19, 2021.

Text editor powered by tinymce.