Building a Clock with an Arduino | CodeGuru

Building a Clock with an Arduino

Introduction Building a clock with Arduino is easier than you think. All you need to get started is an Arduino prototyping board and some type of display, preferably one with at least eight characters. I will be using an Arduino Uno board with a Sparkfun 16×2 LCD display. To set the time on the Arduino, […]

Written By
Dylan Sweaza
Dylan Sweaza
Sep 18, 2015
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Introduction

Building a clock with Arduino is easier than you think. All you need to get started is an Arduino prototyping board and some type of display, preferably one with at least eight characters. I will be using an Arduino Uno board with a Sparkfun 16×2 LCD display. To set the time on the Arduino, we will be sending a Unix Timestamp over serial using the Arduino IDE Serial Monitor.

Arduino Clock

Shopping List

You will need the following items for this project. They are all readily available at any hobby shop or online.

  • 1 Arduino Uno
  • 1 16×2 Character LCD Display
  • 1 Breadboard
  • 1 USB Cable
  • 1 Potentiometer
  • 1 220 Ohms Resistor
  • Several Jumper Wires

Arduino Circuitry

Look at the wiring diagram below to connect the LCD display with the Arduino Uno. It may look a little confusing, but it is very straight forward. Six jumper wires are connected from pins on the display to the Arduino headers. Ground is connected three times on the display; +5v once, and 220Ohms +5v are connected once.

The potentiometer is connected to Ground and +5v with the middle pin connected to the 3rd pin from the left on the display. The potentiometer is used to control the contrast of the display to make the characters readable.

The display should be connected to pins 2, 3, 4, 5, 11, and 12 on the Arduino.

Advertisement

Arduino Circuit Board

Arduino Code

There are two different libraries we will use for this project. One is the LiquidCrystal Library that comes packaged with the Arduino IDE. The second library is the Time Library created by Michael Margolis. As the two names imply, LiquidCrystal will be used to control the display, and Time will be used to keep track of the time.

I will discuss the major parts of the Arduino code; however, check out the download for the entire code file that is full of comments!

Install Time Library

Time Library is not packaged with the Arduino IDE. Download the library from

Board

Setting Arduino Time - 1

Setting Arduino Time - 2

Running Arduino Clock

Now What?

Congrats on creating your first Arduino Clock! But, now what? Now that you know how to tell time with Arduino, you can create smarter Internet of Everything (IoE) devices that are aware of the time. Automate the blinds in your house to open and close at a certain time of day. Create something with a bang that will really get people’s attention! 

References / Resources

# # #

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.