Binary Clock on a 5x8 Matrix Display

By Brian Reed

Overview

This project is a binary clock. The clock displays the time in a binary format on a 5x8 LED matrix. The first two columns display hours, the fourth and fifth columns display minutes, and the last two display the seconds.

Front view

Hardware

The microcontroller used is the R5F1036AA. I used the DS3231MZ, a highly accurate real-time clock (RTC) that uses the I2C protocol, to keep time. The values that are returned are formatted to show the time in a binary equivalent of a decimal format. In other words, each byte corresponds to a digit that would be displayed on a digital clock and each lit column represents a digit. The device is powered via a mini-USB port. The RTC is connected to a CR2032 battery so that the clock will not be reset when the device is not plugged in. Two buttons are dedicated to changing the time on the real-time clock. One increments hours and the other increments minutes.

Schematic Board layout

Software

All of the code is written in assembly. Upon startup, the ports, 8 MHz LS clock, I2C, and interval timer are setup and variables are initialized in RAM. The RTC provides an interrupt every second and the time is received in BCD format. In the main loop, the microcontroller is put to sleep and is woken after 2ms by the 12-bit interval timer. After waking, the time is displayed by lighting up the LEDs in each column from left to right, one column at a time. The display is refreshed at a rate high enough that flicker is not seen. Every 16 ms the microcontroller determines whether a button has been pressed. When a button is pressed, the time is increased in RAM and the new value is sent to the RTC.

Downloads


Last modified:Mon, Jan 23, 2023.

00238