Arduino LED matrix binary clock

Teodor Costachioiu
Jan 22, 2019 · 3 min read
Image for post
Image for post

Last days I revisited some older projects on the blog looking for a source of inspiration, and I realized that I did not publish too many clock projects. Well, it’s time to fix this: today I will show you how to make a binary clock using one Arduino Uno, and one Arduino Uno Click shield, one 8×8 LED matrix B click and one RTC2 Click from MikroElektronika.

As usual, when working with MikroElektronika click boards, the hardware part is deceptively simple: attach the Arduino Uno Click shield on top of the Arduino Uno board. Put the 4×4 B click in mikroBUS socket #1. Put the RTC2 click into mikroBUS socket #2. That’s all. Both click boards are designed to run on 5V power, so there’s no need to change jumpers and such.

Binary clock Arduino code

As prerequisites, besides the hardware, one has to install the following code libraries:

The code comes in two flavors, one that shows one binary value for each digit of the hour, minute and seconds respectively; the other version shows each of the hours, minutes and seconds as a single binary value.

Both version will update the RTC values when the program is compiled and uploaded, so there is no need to set the time separately. Then, the RTC is configured to output an 1Hz square wave on its INT pin — that corresponds to pin D3 on the Arduino Board.

In the Arduino code, an interrupt is generated every second. The ISR routine sets the is_second variable to “true”. In the main loop, the value of this variable is tested and, if true, the LED matrix is updated and the is_second variable is cleared.

The main difference between the two codes is within the update_display() routine that updates the LED matrix.

In the first version, each of the hours, minutes and seconds is split into two digits, one for the tens and one for the units. A look-up table is used to convert those values into meaningful binary values that are then shown onto the LED matrix.

In the second version of the code each of the hours, minutes and seconds are shown as a single binary value. Again, a look-up table is used to convert time into meaningful binary values. However, in this version, the look-up table is much larger because the possible values now range between 0 and 59.

Originally published at https://electronza.com on January 22, 2019. Moved on Medium on April 23, 2020.

Electronza

DIY electronics projects and more

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store