Arduino Based LCD Digital Clock

22,846

32

10

Published

Introduction: Arduino Based LCD Digital Clock

About: A place for DIY projects

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.

Share

Recommendations

  • Clocks Contest

    Clocks Contest
  • Water Contest

    Water Contest
  • Creative Misuse Contest

    Creative Misuse Contest

10 Discussions

0
user
SoTholT

Question 4 months ago

why i can't download alarm clock code?

0
user
truep2

5 months ago

hello any bro help me plz send a code ARDUINO BASED LCD DIGITAL CLOCK my id beeb22jaan9595@gmail.com...step 5 no work my pc...

hello bro i want to code plz help me

Thanks the author

I have a question

Make sure to set you more time

Hi, which IO pin is set for the alrm?

thnx

billd

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

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

1 reply

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

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

1 reply

The download link is listed in Step 5