Arduino Based LCD Digital Clock

29,196

34

16

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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.

1 Person Made This Project!

Recommendations

  • Magnets Challenge

    Magnets Challenge
  • Raspberry Pi Contest 2020

    Raspberry Pi Contest 2020
  • Wearables Contest

    Wearables Contest

16 Discussions

0
manna69
manna69

Question 2 months ago

ciao a tutti il mio perfetto funzionamento, ma quando imposto la sveglia per il giorno successivo non suona mi può aiutare grazie. sul display.

0
manna69
manna69

Answer 2 months ago


what chat is anybody there?

0
manna69
manna69

2 months ago

Salve sono Nicola grazie x la risposta.

0
DevinH5
DevinH5

3 years ago

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

0
smching
smching

Reply 3 years ago

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

0
AltairThA
AltairThA

Reply 5 months ago

It won`t work. It`s making a single beep just for a 0.5-1sec and then triggering alarm auto off.
fixed by commenting string №71 in main sketch. Now it squelling continuously until I`ll shut it manually.
Not good way to fix, but better then single short beep)
Of course it`ll be great if you can make some updates. Thnx :)
(sorry 4 bad English if any)

0
rwl7532
rwl7532

7 months ago on Introduction

'dateStr' was not declared in this scope is the error I'm getting with IDE 1.8.9
Same with timeStr

0
rwl7532
rwl7532

Reply 5 months ago

All modules must be in the same folder. It works when that was done.

0
SoTholT
SoTholT

Question 1 year ago

why i can't download alarm clock code?

0
truep2
truep2

1 year 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...

0
truep2
truep2

Question 1 year ago on Step 5

hello bro i want to code plz help me

0
thiện phún
thiện phún

2 years ago

Thanks the author

I have a question

Make sure to set you more time

0
Billd39ET
Billd39ET

3 years ago

Hi, which IO pin is set for the alrm?

thnx

billd

0
Billd39ET
Billd39ET

3 years ago

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

0
MinendraR
MinendraR

3 years ago

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

0
smching
smching

Reply 3 years ago

The download link is listed in Step 5