top of page


How to make a digital clock with an Arduino uno a RTC and a 7 segment display

Hey friends Makers,

I want to talk today about digital. I know it's everywhere around us but it's sometimes good to put the hands-on to make your own DIY project.

So, the tutorial today will focus on how to make a digital clock with an Arduino uno board, a RTC (real time clock : we made an tutorial on it not too long ago) and 4 digits 7 segments display.

This homemade digital clock will display minutes and hours.


So to start, we need to gather the the following hardware:

The DS1307 RTC connects to our arduino uno with the I2C protocol ''SDA and SCL'' lines. Everything is manage by the I2C library.

The 4 digits 7 segments also works with the I2C protocol. What makes it easier to handle with the I2C library.


You can now connect all the differents modules ( DS1307 RTC and 4 digits 7 segment display) with the arduino uno to make the digital clock by following the next schematic.

The I2C pins on the arduino side work with 4 lines that are the following:

  • 5V for the power

  • GND for the ground

  • A4: SDA for the data

  • A5: SCL for the clock

Install the libraries ( DS1307 RTC and 4 digits 7 segment for the I2C protocol)

The Library for the 4 digits 7 segments can be download with the following link: Library 4 digits 7 segment_LED_Backpack Led and Adafruit_GFX_Library

The library for the RTC library can be dowload with the following link: Library I2C DS1307 RTC

After downloading the libraries, you need to install them in your Arduino IDE ''librarie'' directory by unziping them in it. Then restart your Arduino IDE.

Install the main program for the digital clock

Now, you need to copy and upload the following code to your arduino uno. The time will be set automatically to the the internet time where you are located:

#include <Wire.h>

#include "Adafruit_LEDBackpack.h" //Library for the 7 segment display

#include "Adafruit_GFX.h"

#include "RTClib.h" // Library for the RTC


Adafruit_7segment disp = Adafruit_7segment();

void setup()




if (! RTC.isrunning())


RTC.adjust(DateTime(__DATE__, __TIME__));




void loop()










int getDecimalTime()


DateTime now =;

int decimalTime = now.hour() * 100 + now.minute();

return decimalTime;



That was a fun tutorial where you have learn how to make a digital clock with 2 modules ( ) and a few lines of code.

All this make it ieasier to make this project and for a pretty good price. And you can reuse the materiels (Arduino, DS1307 RTC module and the 4 digits 7 segment) in another project. You can of course use another arduino board like an arduino mega, an arduino nano and so on.

Please come back to us if you make a digital clock and tell us about your experience when doing it or even if you modified it to create another project.

If you like the tutorial. Please leave a thumb up or a comment and don't forget to subscribe to our newsletter on the front page of our website '''' (lower bottom) and the social medias (Facebook, Twitter, Google+, Instagram, Youtube).

Take care and see you for another article.