For a while now I have fancied building a binary clock. A clock capable of showing the current time in binary format. Not only do they look great but you have the added bonus that most people probably wont have any idea what an earth they are looking at. For those who have no idea what a binary clock is I would highly recommend this Wikipedia page for more information.
To keep things simple I decided on a Binary Coded Decimal (BCD) format rather than pure binary or grey scale. With BCD the hours, minutes and seconds are all represented by individual binary digits. That way you simply add each digit together to determine the number of hours followed by the number of minutes and finally the number seconds.
I wanted something fairly portable, preferably USB powered and reasonably cheap. I ended up using an Arduino Nano clone, a 0.96″ 128×64 OLED display module and a DS3231 real time clock module. This configuration fitted the bill perfectly.
I love these little OLED displays. They are extremely bright and easy to use. The majority if not all of the ones I found on eBay use the SSD1306 display driver chip. The SSD1306 supports a number of interfaces formats including parallel, SPI and I²C. The module I purchased uses an I²C bus.
The DS3231 I have used on lots of projects before. These devices are extremely accurate with minimal drift over time. Not a lot to say about these really the device maintains seconds, minutes, hours, day, date, month, and year information. Has two configurable alarms and even has an internal temperature sensor (which is used for temperature compensation of the oscillator) but can also be read via one of the internal registers. Data is transferred serially through an I²C bus.
The OLED display supports two colours. The very top of the display uses yellow on black while the remainder of the display uses blue on black. I decided to take advantage of this and alternate between the current time, date and temperature along the top while showing the current time in binary format below using rectangles to represent each binary bit. I am really pleased with the way it turned out.
The design was implemented on breadboard and all of the code written in C using the Atmel Studio development environment. Rather than continually reading the time from the DS3231 its square wave output pin was configured to output a 1Hz square wave which in turn was connected to one of the external interrupts pins on the ATMega328. Upon interrupt the interrupt handler simply sets a flag to indicate to the main exec to read the time and refresh the display. The clock has been running fine now for around four months with no issues at all. All of the project files and source code will be available in my GitHub account.