LCD clock

By Jinchuan X.

Overview

In this project, we design a digital clock based on an LCD display with background light. The first line on the display shows the time and the temperature in °C. The second line shows the date in MM/DD/YY format.

Hardware

There are three buttons on this clock: alarm/set, and the other two. By pressing the alarm/set button we can change the state of the clock, with the other two buttons we can adjust the time and date. The clock is powered by a 5.3V cell phone charger, the on-board power regulator converts it down to 3.3V, which is needed for the used LCD. The clock is also equipped with CR2032 backup battery.

Schematic Front view Back view

The clock consists of three buttons, MCP9802 temperature sensor with I2C interface, and LCD display interfaced in a 4-wire mode. We used Attiny24 as CPU. The DS1339C real-time clock stores the time. The device has a buzzer which is activated at the alarm time. The LCD display has two lines with background light. Each line can represent eight characters.

Software

I used the AVR Studio to design and debug the program. The main part of the code is to set up the three buttons. There are four states in the clock. The state is changed by pressing the alarm button when the buzzer is off. The other two buttons work differently in various states. The first state is when the display shows current time. The time setting buttons are used to adjust minutes and hours to the real time. If you press the alarm button, the state changes from the normal display state to the alarm set-up state. The time on display would change to the alarm time. Now the time setting buttons are used to set up the minutes and hours of the alarm. If you press the alarm button again, the state would change to the month/date set-up state. Simultaneously, the alarm time would change back to the original real time. In this state the time setting buttons are used to set up date and month. By pressing the alarm button again the state changes to the year set up state. The hours setting button is used to increment the year, while the minutes setting button is used to decrement it. Now if we press the button again the state would change back to the initial state. When the buzzer is on, pressing the alarm button would just turn off the buzzer. If the alarm is active for one minute, it turns itself off automatically. Another part of the code is to set up the temperature sensor. The display of temperature would update as the change of the temperature around it.

Downloads


Last modified:Mon, Jan 23, 2023.

00937