Arduino LED matrix binary clock

0

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:

  • LED Control library from https://github.com/wayoda/LedControl. This is the library that works best with the 8×8 B click – it’s the same library I used before, in the game of life project.
  • DS1307 RTC library from https://github.com/adafruit/RTClib. There are many libraries available for the DS1307, but this project requires one library that “knows” how to configure the RTC for SQW output.

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.

The Arduino Uno is configured for the

Thus, 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 is 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.

 

Share.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: