Introduction: Simple Digital Clock Using Arduino Nano & DS1307

About: someone who likes electronics

In this article I will show you a tutorial to make a digital clock using Arduino.. The Arduino board that I use is Arduino Nano V3, DS1307 as a time data provider, MAX7219 7 Segment as the watch display.

before entering the tutorial, I recommend that you are familiar with using Arduino devices and accessories. This will make it easier for you to follow the tutorial that I showed.

If you are not familiar with using Arduino boards, don't worry.

You can read this article to warm up:

Step 1: Required Components

these are the components we need to make a digital clock:

Library Required :

Step 2: Assemble All Components

If all components have been obtained, Now it's time to assemble.

See the description below or see the picture above:

Arduino to RTC DS1307


+5V => VCC

A4 => SDA

A5 => SCL

Arduino to MAX7219

+5V => VCC


D12 => DIN

D11 => CLK

D10 => CS

After all components are installed, continue to the programming section.

Step 3: Programming

copy and paste this sketch into the sketch that you made. After that upload the program to the arduno board

#include "LedControl.h" #include "RTClib.h"

RTC_DS1307 rtc; LedControl lc=LedControl(12,11,10,1);

void setup() { Serial.begin(57600); if (! rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } if (! rtc.isrunning()) { Serial.println("RTC is NOT running!"); // following line sets the RTC to the date & time this sketch was compiled // rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } lc.shutdown(0,false); lc.setIntensity(0,8); lc.clearDisplay(0); }

void loop() { DateTime now =; if(now.second() < 30 || now.second() > 40) { lc.setDigit(0,0,now.second()%10,false); lc.setDigit(0,1,now.second()/10,false); lc.setChar(0,2,'-',false); lc.setDigit(0,3,now.minute()%10,false); lc.setDigit(0,4,now.minute()/10,false); lc.setChar(0,5,'-',false); lc.setDigit(0,6,now.hour()%10,false); lc.setDigit(0,7,now.hour()/10,false); }

if (now.second() == 30 || now.second() == 40) { lc.clearDisplay(0); }

if(now.second() >= 31 && now.second() < 40) { lc.setDigit(0,6,,true); lc.setDigit(0,7,,false); lc.setDigit(0,4,now.month()%10,true); lc.setDigit(0,5,now.month()/10,false); lc.setDigit(0,0,(now.year()%1000)%10,false); lc.setDigit(0,1,(now.year()%1000)/10,false); lc.setDigit(0,2,(now.year()%1000)/100,false); lc.setDigit(0,3,now.year()/1000,false); } }

Step 4: Result

After all the steps are successful, this is the result that you will see: (watch video)

every 31st second to 40th second. 7 Segments will display the date. Except for that second, 7 segment will display the clock