Digital clock

Confidence Idim

Overview

For this project, I created a digital clock that uses a low power mode to maximize battery life. The project uses a 2x16 LCD screen that displays the time in HH:MM format and the date in the DD/MM/YYYY format. It also displays a greeting message at the bottom of the LCD screen which depends on time. It can be powered through a USB cable or battery.

General view

Hardware

For this project, I used a Freescale MKL05Z32VFK4 Kinetis microcontroller from the KL05 Kinetis family series because of it is efficient, and it has good low power mode capability which prolongs battery life. I used a 2x16 character Newhaven LCD display with backlight. The time is updated by the DS3231MZ real-time clock. The DS3231MZ real-time clock is powered by a CR2032 battery when the alarm clock is not powered on to keep the time updated.

Schematic Assembly

The microcontroller is clocked at 4 MHz frequency whenever active, and the entire circuit consumes less than 2 mA of current. Press of the middle button leads to turning the LCD back light on and off. The other two buttons are used to set dat and time as explained below. The clock produces a short beep at the beginning of every hour.

Software

This program first configures the hardware and runs through the setup routine. When the main loop runs, there is a function that checks to see if the buttons are pressed and performs the function based on the current clock state. In any state except for the set minute state, if the minute variable is equal to 0 (signifying that an hour has passed), the buzzer starts to beep. It beeps and stops after about 100 milliseconds. The clock has no alarm.

fsm

Here is the button usage:

B1
Button 1 (left button/change state button). This button is used to change the clock states.
B2
Button 2 (middle button). This button is used to turn the LCD backlight on/off and is also used to increment hours/minutes/month/date/year depending on state.
B3
Button 3 (right button). This button changes the clock mode to state 0.

Final Thoughts

This is my first big Computer Science project and I had a lot of fun doing it. I would love to have more experience working with microcontrollers in future. I got my project to function as I intended it right from the start of the project and I am happy with that.

Downloads


Last modified:Mon, Jan 23, 2023.

00591