So, now I hope that you have installed both these libraries successfully and are ready to design this DS1307 Arduino based Digital Clock. I have given the Simulation and Code for download below but as I always advise, don't just download the files. Instead design your own simulation and try to write your own code. In this way, you will learn more out of it. So, let's get started with DS1307 Arduino based Digital Clock in Proteus ISIS:
DS1307 Arduino based Digital Clock in Proteus
- You can download the complete Proteus Simulation along with Arduino Code by clicking the below button.
- You will also need DS1307 Library for Arduino, which is also available in this package.
- Now, let's get started with designing of this DS1307 Arduino based Digital Clock.
- So, first of all, design a circuit in Proteus as shown in below figure:

- You can see in the above figure that I have used Arduino UNO along with RTC module, LCD and the four buttons.
- These four buttons will be used to change the year,date etc as mentioned on each of them.
- Now here's the code for DS1307 Arduino based Digital Clock.
#include <LiquidCrystal.h> #include <DS1307.h> #include <Wire.h> LiquidCrystal lcd(13,12,11,10,9,8); int clock[7]; void setup(){ for(int i=3;i<8;i++){ pinMode(i,INPUT); } lcd.begin(20,2); DS1307.begin(); DS1307.setDate(16,4,7,0,17,50,04);//ano,mes,dia,semana,horas,minutos,segundos } void loop(){ DS1307.getDate(clock); lcd.setCursor(0,1); lcd.print("Time: "); Print(clock[4]); lcd.print(":"); Print(clock[5]); lcd.print(":"); Print(clock[6]); lcd.setCursor(0,0); lcd.print("Date: "); Print(clock[1]); lcd.print("/"); Print(clock[2]); lcd.print("/"); lcd.print("20"); Print(clock[0]); if(digitalRead(7)){ clock[5]++; if(clock[5]>59) clock[5]=0; DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]); while(digitalRead(7)); } if(digitalRead(6)){ clock[4]++; if(clock[4]>23) clock[4]=0; DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]); while(digitalRead(6)); } if(digitalRead(5)){ clock[2]++; if(clock[2]>31) clock[2]=1; DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]); while(digitalRead(5)); } if(digitalRead(4)){ clock[1]++; if(clock[1]>12) clock[1]=1; DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]); while(digitalRead(4)); } if(digitalRead(3)){ clock[0]++; if(clock[0]>99) clock[0]=0; DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]); while(digitalRead(3)); } delay(100); } void Print(int number){ lcd.print(number/10); lcd.print(number%10); }
- Now get your hex file from Arduino software and then upload it in your Proteus software.
- Now run your simulation and if everything goes fine, then it will look like something as shown in below figure:

- Now you can see its today's date in the LCD and the same is shown over on the small pop up of DS1307 Clock.
- Now the time will start on ticking and the buttons will used to change the minutes hours etc.
- You will get the better demonstration of this project in the below video.