Introduction: Arduino Based LCD Digital Clock

This is an Arduino based digital Clock to display real time on a 16x2 LCD using a DS1307RTC module. The date and time can be set via serial interface or push button switches.

Step 1: Features

  1. Shows date and time on serial monitor.
  2. Shows date and time on a mini LCD.
  3. Alarm clock - turn ON or turn OFF an IO pin.
  4. Settings can be set via serial interface or push button switches.
  5. Keeps time running after electricity failure.
  6. Using an Arduino UNO & a LCD Keypard Shield.
  7. Using a DS1307 RTC module.

Step 2: Software Library

You need to download and install the following libraries before you can upload sketch to your Arduino.

Time.h

Time library adds timekeeping functionality to Arduino with or without external timekeeping hardware. This library is often used together with TimeAlarms and DS1307RTC.

DS1307RTC.h

Allows you to access real time clock (RTC) chips compatible with the DS1307.

Step 3: LCD Keypad Shield

The LCD Keypad shield includes 6 momentary push buttons and a blue backlight LCD which can display two row of 16 characters. The buttons are connected to only one analog input (A0) in order to saving on input/output pins.

Step 4: DS1307RTC Module

The DS1307 serial real-time clock (RTC) is a low- power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. DS1307 works on I2C protocol which can interfaces to most microcontrollers.

A 3 volt lithium coin cell battery (CR2032) is connected to the DS1307 which keeps time running after electricity failure. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply. The module also include a 24C32 32K I2C EEPROM which is not using in this project.

Step 5: Source Code

This project includes three examples that shows how to display real time on a LCD display with or without using a RTC module.

  1. LCD Digital clock without RTC module.
  2. DS1307RTC LCD Digital clock.
  3. DS1307RTC LCD Digital clock with Alarm.

The Arduino code is breaking into multiple files which make it more readable and hence easy to maintain.

Step 6: Key Functions

Step 7: Set Date/Time Via Serial Interface

  • Run the Serial terminal.
  • Make sure you have selected the the correct COM port.
  • Make sure the baud rate is set correctly at 9600 bps.
  • To set the system date, send a string to the serial port with the following syntax:

Syntax: Dyymmnn
E.g. D160415 will set the system date to 2016 April 15th

  • To set the system time, send a string to the serial port with the following syntax:

Syntax: Thhmmss

E.g. T012345 will set the system time to 1AM 23minute 45seconds

  • To set the Alarm time, send a string to the serial port with the following syntax:

Syntax: Ahhmmss

Step 8: Set the Date Via Push Buttons

  1. Push the Right button in order to change the system date.
  2. Use the Up/Down buttons to change the date.
  3. Push the Select button to accept changes.
  4. Timeout will occur after idle for 10 seconds, changes made will not save.

Step 9: Set the Time Via Push Buttons

  1. Push the Left button in order to change the system time.
  2. Use the Up/Down buttons to change the time.
  3. Push the Select button to accept changes.
  4. Timeout will occur after idle for 10 seconds, changes made will not save.

Step 10: Set the Alarm Time Via Push Buttons

  1. Push the Up button in order to change the alarm time.
  2. Use the Up/Down buttons to change the time.
  3. Push the Select button to accept changes.
  4. Timeout will occur after idle for 10 seconds, changes made will not save.

Step 11: Disable/Enable Alarm

  1. Push the Down button to disable or enable Alarm.
  2. If Alarm is enabled, its time is shown on the right corner of the LCD.
  3. If Alarm is disabled, its time is hidden.

Comments

author
thi%E1%BB%87n+ph%C3%BAn made it!(author)2017-03-22

Thanks the author

I have a question

Make sure to set you more time

author
BillD120 made it!(author)2017-01-05

Disregard my previous comments, I found the IO pin (A3) in your alarm.ino file. I was able to get an LED to switch on at the alarm time, however without a current limiting resistor the auto-off for the alarm, (10 secs), did not work. With the resistor the LED and the Alarm Off display worked fine.

I changed to pin D13 and found the same issue.

Any idea why the LED without resistor would stop the auto-off function for the alarm?

FYI I sued a data logging module I had with an on-board RTC chip. worked fine with the DS1307RTC library.

thnx

billd

Again, thnx for a great instructable!

IMG_2854.JPGIMG_2855.JPG
author
smching made it!(author)2017-01-14

You may burn the LED without the limiting resistor.

author
BillD120 made it!(author)2017-01-05

Hi, which IO pin is set for the alrm?

thnx

billd

author
BillD120 made it!(author)2017-01-04

HI, great instructable, very good explanation of the hardware features. Do you have a connection wiring diagram please?

author
DevinH5 made it!(author)2016-09-30

How to change the auto turn off alarm from 10 seconds to a minute?

author
smching made it!(author)2016-10-01

Open the alamm.ino file, change #define ALARM_AUTO_OFF 10 (line 3) to #define ALARM_AUTO_OFF 60

author
MinendraR made it!(author)2016-08-06

Can you please give us the code for the LCD Date and Time clock

author
smching made it!(author)2016-08-15

The download link is listed in Step 5

About This Instructable

16,510views

30favorites

License:

Bio: A place for DIY projects
More by smching:How to create webpages & setup website using Joomla CMSLearning, Experience and Review the Makeblock 3 in 1 MBot Ranger Robot KitArduino Based LCD Digital Clock
Add instructable to: