Genrally Now a days we use Mobile Phones to Set Alarm and to see time but it pain in the to click the button search for the mobile to see time and setting Multiple alarms like a continuty series( a 5 min interval alarm x times)  and major thing is the volume maximum time our mobile phones are in silent ......result late at work So, we can make a device that can relieve us from this pain saves time and is Trustfull not to make you late anywhere. Arduino Digital Clock can do these things for you so let's start.



 



New Things we will Learn through this Tutorial 



1. RTC(Real time Clock)



2. EEPROM 



Using I2C chip to display and many more.



RTC



Real time clock is the lib. in the Arduino which uses the DS1307 Module to Read and Modify time. 



EEPROM



This Lib. is used to use the Memory space in Arduino to store Information that has to be saved. Thess Datas are not wiped if we turn off the Arduino.  



 



REQUIREMENTS



1. Arduino





2. 2x16 display module and I2C module 





 



3. RTC module with DS1307 IC





 



 



4. Jumper Wires



 



5. 2 pin button switches





6. Small Breadboard



 



PROCEDURE-:



1. Connect the Vcc and Gnd pin of the RTC module and I2C module to the Arduino Vcc and GND Pin(Use Bread board/veroboard);



2. Connect the SDA pin to A4 and SCL pin to A5 of the Arduino and SDA,SCL of both the RTC module and I2C Module.(use breadboard/veroboard)





3. Now Upload the Code and you can see the time and date is displayed the code is shown below.




#include
#include
#include
#include
#include
//LiquidCrystal lcd(3, 2, 4, 5, 6, 7);
RTC_DS1307 RTC;
int temp,inc,hours1,minut,add=11;

int next=10;
int INC=11;
int set_mad=12;
LiquidCrystal_I2C lcd(0x27, 7, 8);
#define buzzer 13
int addr=11;
int HOUR,MINUT,SECOND;
int split=0,count=0;
int cnt=0;
int i1=0;
int cub=0;
void setup()
{
Wire.begin();
RTC.begin();
lcd.begin();
pinMode(INC, INPUT);
pinMode(next, INPUT);
pinMode(set_mad, INPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(next, HIGH);
digitalWrite(set_mad, HIGH);
digitalWrite(INC, HIGH);

lcd.setCursor(0,0);
lcd.print("Real Time Clock");
lcd.setCursor(0,1);
lcd.print("Circuit Digest ");
delay(2000);

if(!RTC.isrunning())
{
RTC.adjust(DateTime(__DATE__,__TIME__));
}
}

void loop()
{
int temp=0,val=1,temp4;
DateTime now = RTC.now();
if(digitalRead(set_mad) == 0) //set Alarm time
{
lcd.setCursor(0,0);
lcd.print(" Set Alarm ");
delay(2000);
defualt();
time();
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Alarm time ");
lcd.setCursor(0,1);
lcd.print(" has been set ");
delay(2000);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Time:");
lcd.setCursor(6,0);
lcd.print(HOUR=now.hour(),DEC);
lcd.print(":");
lcd.print(MINUT=now.minute(),DEC);
lcd.print(":");
lcd.print(SECOND=now.second(),DEC);
lcd.setCursor(0,1);
lcd.print("Date: ");
lcd.print(now.day(),DEC);
lcd.print("/");
lcd.print(now.month(),DEC);
lcd.print("/");
lcd.print(now.year(),DEC);
match();
delay(200);
}

void defualt()
{
lcd.setCursor(0,1);
lcd.print(HOUR);
lcd.print(":");
lcd.print(MINUT);
lcd.print(":");
lcd.print(SECOND);
}

/*Function to set alarm time and feed time into Internal eeprom*/

void time()
{
int temp=1,minuts=0,hours=0,seconds=0;
while(temp==1)
{
if(digitalRead(INC)==0)
{
HOUR++;
if(HOUR==24)
{
HOUR=0;
}
while(digitalRead(INC)==0);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Set Alarm Time ");
//lcd.print(x);
lcd.setCursor(0,1);
lcd.print(HOUR);
lcd.print(":");
lcd.print(MINUT);
lcd.print(":");
lcd.print(SECOND);
delay(100);
if(digitalRead(next)==0)
{
hours1=HOUR;
EEPROM.write(addr++,hours1);
temp=2;
while(digitalRead(next)==0);
}
}

while(temp==2)
{

if(digitalRead(INC)==0)
{
MINUT++;
if(MINUT==60)
{MINUT=0;
}
while(digitalRead(INC)==0);
}
// lcd.clear();
lcd.setCursor(0,1);
lcd.print(HOUR);
lcd.print(":");
lcd.print(MINUT);
lcd.print(":");
lcd.print(SECOND);
delay(100);
if(digitalRead(next)==0)
{
minut=MINUT;
EEPROM.write(addr++, minut);
temp=3;
while(digitalRead(next)==0);
}
}
while(temp==3)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Interval of Alarm ");
if(digitalRead(INC)==0)
{
split++;
if(split==20)
{split=0;
}
while(digitalRead(INC)==0);
}
// lcd.clear();
lcd.setCursor(0,1);
lcd.print(split);
delay(100);
if(digitalRead(next)==0)
{
EEPROM.write(addr++, split);
temp=4;
while(digitalRead(next)==0);
}
}
while(temp==4)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Times to Repeat(on Interval)");
if(digitalRead(INC)==0)
{
count++;
if(count==20)
{count=0;
}
while(digitalRead(INC)==0);
}

// lcd.clear();
lcd.setCursor(0,1);
lcd.print(count);
delay(100);
if(digitalRead(next)==0)
{
EEPROM.write(addr++, count);
temp=0;
while(digitalRead(next)==0);
}

}
delay(1000);
}

/* Function to chack medication time */

void match()
{
int tem[17];
for(int i=11;i<17;i++)
{
tem[i]=EEPROM.read(i);
}

if(HOUR == tem[11] && MINUT == tem[12])
{
if(cub==0)
{
cnt++;
cub++;
}
addr=11;
beep();
beep();
beep();
beep();
lcd.clear();
lcd.print("Wake Up........");
lcd.setCursor(0,1);
lcd.print("Wake Up.......");
beep();
beep();
beep();
beep();
i1=0;
}
else
{
if((tem[14]>=cnt) && (cnt > i1 ))
{
i1=cnt;
cub=0;
lcd.clear();
lcd.print("Next Alarm Set.!!");
int time1=tem[13]+MINUT-1;
if(time1>=60)
{
EEPROM.write(11, tem[11]+1);
EEPROM.write(12, time1-60);
}
else
{
EEPROM.write(12, time1);
}
delay(1000);
}
}
}

/* function to buzzer indication */

void beep()
{
digitalWrite(buzzer,HIGH);
delay(500);
digitalWrite(buzzer, LOW);
delay(500);
}


4. Now to Control the Switch Connect Pin 13 to Positive of Buzzer, Pin 12 to one pin of the switch, Pin 11 to one pin of another switch, Pin 10 to one pin of another switch





5. Now to use it See the Video and Learn.



 



Final Connections 





Video-: