So let us make a cool Arduino LCD clock. the clock will tell us the time on an LCD display.

This is a great way of learning how to interface various sensors to the Arduino Uno. On a scale of 1-10 I would say this falls at difficulty level of 4. the prerequisite of this project is that you should be familiar at using the Arduino microcontroller and Arduino IDE software.

The parts that will be requiring to make this are:

  • Arduino Uno (actually any other arduino will do too)
  • bunch of connecting wires (multicolored)
  • breadboard (preferably small sized)
  • DS- 1302 Real time clock module
  • Serial 16×2 Character LCD
  • 9V battery

I have purchased all the above parts from ,you are free to buy parts from your local electronic store,from other sites that sell electronic parts or any other e-commerce store.

Let us begin

The part that tells us the time is the DS-1302 clock. we need to set the correct value of time on this clock first. once the clock is set we no longer need to set the time again. There is a very useful guide on the web for the DS-1302 interfacing here by T.Murphy.The blog is very helpful and please feel free to go through the blog. He has also uploaded a library for the DS1302. we will make use of this library. the library has made our work much, much easier.

Steps to install the DS-1302 library in Arduino

  • Just go to the code section of the blog and download the VirtuabotixRTC is in the form of a zip file.
  • Extract the zip file to the folder where you have installed Arduino software.
  • Also, cut and paste the two Examples that are included to the examples folder in the Arduino folder. This should make the examples accessible through the Arduino IDE software.
  • Just check this by opening the software and clicking on the File menu and then on examples. you should find the two examples listed there.

The DS-1302 Real time clock

Here is the DS-1302 Real time clock we will be using.


As you can see it has 5 pins labelled VCC, GND, CLK, DAT, RST

DS-1302 real time clock

It comes along with a CR2032 battery, commonly found in watches and calculators. It is a backup source of power. it stores the time when we do not have the arduino attached. we just need to update time and the clock will give us time as long as the battery does not die or we remove the battery from the RTC module.

Steps to set the time on the DS-1302 clock

  • Snap the battery into the RTC module and connect as per the diagram shown belowDS-1302 connected.jpg
  • Open up the first example in Arduino software i.e. VirtuabotixRTC_version1 .
  • In the first few lines of code you will find a function myRTC.setDS1302Time that will set the time for us as shown in pic below.3.jpg
  • Edit the function values and set the current time.
  • Upload the sketch to the arduino.This will update the time on the clock.
  • To check if this is done open the serial port from the arduino software. you should see the values of time being printed every 5 seconds.

That was the hardest part int this tutorial. hope you are still with me.

The Serial 16X2 Character LCD display

Lets get to the LCD display that we shall be using.Serial LCD module front

this is a 16×2 LCD module. this is a higher priced variant of the LCD module. the good part is that it requires only 3 pins to be connected to the arduino as opposed to the conventional 16 pins. This can be a lifesaver if you are making use of microcontroller which has a few no of output pins. eg.  Arduino UNO

Serial LCD module back

Here is the pic of the back of the LCD display. as you can see there are only 3 pins i.e VCC, GND, RX.

The Final part

Lets connect all Parts together and get our clock working. Follow the steps

  • Upload the code below for the Arduino clock to the arduino. here is the Arduino program.

//23/12/15 ver.1.1

virtuabotixRTC myRTC(6, 7, 8);
int day,year,hours,minutes,seconds, month;

void setup()

void loop()

void init_lcd()
  int backlight_on = 17;
  int backlight_off = 18;
  int line_feed = 10;
  int clear_disp = 12; //clears screen; provide 5ms delay


void clock()

void lcd_write()
  if( myRTC.dayofmonth != day)
    if (myRTC.dayofmonth<9)
    day = myRTC.dayofmonth;
  if (myRTC.month != month)
    if (myRTC.month<9)
    month = myRTC.month;
  if (myRTC.year != year)
    year = myRTC.year;
  if (myRTC.hours != hours)
    if (myRTC.hours<9)
    hours = myRTC.hours;
  if (myRTC.minutes != minutes)
    if (myRTC.minutes<9)
    minutes = myRTC.minutes;
  if (myRTC.seconds != seconds)
    if (myRTC.seconds<9)
    seconds = myRTC.seconds;

  • Open Arduino software
  • Copy and paste the above program in Arduino software
  • Verify the code in the software. If everything is good You’ll have no errors.
  • Connect all parts as per the circuit diagram below

IMPORTANT:Remember that the TX pin(transmit) connects to the RX(recieve) pin of the LCD module.

DS-1302 connected

  • Upload the code to the Arduino
  • Press the reset button, wait for a few seconds for the clock to print its data.

TIP:press the reset button if you encounter any problems.

There you have it folks you have just built a LCD clock.Serial LC D module showing time

In the Next blog i will show you some cool features that can be added to the Clock. This is the first blog that I have written.I have tried to reduce mistakes as much as possible. please feel free to like, Share and comment if you will.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s