How to make a clock with an arduino and millis() function

In this project we have made a clock using only arduino and a 20×4 character LCD display.

Because arduino give us possibility to count milliseconds through the millis() function, why not to make a clock with it.

First to display we choose a 20×4 characters LCD display  with a I2C communication(it use only two wires for communication and two for power).

Why we choose this module?  It’s simple let us free more pins on the arduino.

Now how to connect it?

In the picture below(right) we see 4 pins:

20x4 lcd20x4 lcd

GND-connect to arduino GND

VCC-connect to arduino 5V

SDA-connect to arduino analog 4

SCL-connect to arduino analog 5

So with connections ready we need to add a library in arduino’s folders to make this lcd work.

This library you can find it here, is the same library we use.

You move it to arduino’s library folder usually C/program files/arduino/library and from arduino software sketch-include library-add zip library- choose the downloaded library .

To adjust the clock we have mounted two button one for minutes and one for hours on Digital pin 8 and Digital pin 7 as you can see in the next picture and in the program.

A connection of parts in fritzing is below:


clock with millis() fritzing

You can download the program from here.


Please let us in the comment zone any suggestions that you think will improve the article!

If you like the article click the follow button from social media to stay in touch with us!


A short video is:


Related posts

Leave a Comment

Show Buttons
Hide Buttons