Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] designing an alarm clock circuit

Status
Not open for further replies.
Dear sir I connected mov But same problom observed.(when bell rings Time stops & keypad not working just like controller stops)last digits on lcd shows but clock stops.
 

Try with this circuit hope u will solve your problem

Siren.png
 

where did you connect your mov? what it's value?
 

Sorry for late reply.I connected mov in output of relay as shown in circuit.rly.ckt.JPG
 

you have to connect MOV between COMMON and NO pins.
 
  • Like
Reactions: tapu

    tapu

    Points: 2
    Helpful Answer Positive Rating
tapu try the circuit i have worked with it.it works fine
HTML:
http://www.nskelectronics.com/automatic_college_bell.html
 

Sorry for late.I connected mov between com & no pins problom have solved.
Here I connect AC mains directly to transformer's primary.are mov's & other components required in power supply section?As the circuit works but in future can it cause problom without mov?
in both cases (relay & power supply)which value of mov is suitable?Please reply
 

it is good to have mov at power supply too. for selection below document will help you.

**broken link removed**
**broken link removed**
 

Dear sir,Now above problom observed again.As mov is connected.what I have to take step now please reply.
 

what is your mov value ? if you have selected the proper value for mov and still having same problem then go for snubber circuit.
 

Dear sir,value of mov 511k D20.which is largest in comp.shop.I have to connect snubber circuit parellel to mov?
(here I did not connect mov in power supply section now).
 

yes you need snubber circuit parallel to MOV and 681k is also available I guess.
 

Dear sir,I connected series connected 103/2kv capacitor & 100R/0.5W resistor(snubber-circuit) parrellel to MOV.But problom is same.
is IC 1232 required to suport microcontroller?
 

Dear sir,Here are circuit & code.cct.JPGpower supply.JPG


Code:
#include <REGX55.H>




sbit set=P1^0;
sbit mov=P1^1;
sbit inc=P1^2;
sbit dec=P1^3;
sbit rly=P1^4;
sbit e5=P1^5;//3rd e5
sbit e6=P2^3;//4th	e6
sbit buz=P2^1;

sbit e4=P1^7;//1st e4
sbit e3=P1^6;//2nd e3
sbit SDA=P2^6;
sbit SCL=P2^7;

bit d;
unsigned char dec_hex(unsigned char tt)
{
if(tt>59)
tt+=36;

else if(tt>49)
tt+=30;
else if(tt>39)
tt+=24;
else if(tt>29)
tt+=18;
else if(tt>19)
tt+=12;
else if(tt>9)
tt+=6;
return(tt);
} 


void all_disp();
void time_set();

void alarm_set1();
void alarm_set2();
void alarm_set3();
void alarm_set4();
void alarm_set5();
void alarm_set6();
void alarm_set7();
void alarm_set8();
void alarm_set9();
void alarm_set10();
void alarm_set11();
void alarm_set12();
void alarm_set13();
void alarm_set14();
void alarm_set15();
void alarm_set16();
void alarm_set17();
void alarm_set18();


void set_date();
void buz_on();
	void blink();
void no_op();





void alarm_chk1();
void alarm_chk2();

void alarm_bell_HI();
void alarm_bell_LOW();
void display_day();
void puls();
void no_puls();




#define First_Line 0x80
#define Second_Line 0xc0
#define Curser_On 0x0f
#define Curser_Off 0x0c
#define Clear_Display 0x01

#define Data_Port P0

sbit Lcd_rs = P2^0;
//sbit Lcd_rw = P2^1;
sbit Lcd_en = P2^2;

sbit sda_rtc =P2^5;
sbit scl_rtc =P2^4;

/*sbit Lcd_rs = P3^5;
sbit Lcd_rw = P3^6;
sbit Lcd_en = P3^7; */

void Lcd8_Init();
void Lcd8_Command(unsigned char);
void Lcd8_Write(unsigned char,unsigned char);
void Lcd8_Display(unsigned char,const unsigned char*,unsigned int);
void Lcd8_decimal2(unsigned char,unsigned char val);
void Delay(unsigned int);
void del();

void hour_mode();


void Seg8_decimal2(min);

void Led8decimal2(hour);
void EEPROM_WriteByte(unsigned char eeprom_Address, unsigned char eeprom_Data);
unsigned char EEPROM_ReadByte(unsigned char eeprom_Address);
void I2C_Start();
void I2C_Stop(void);
void I2C_Ack();
void I2C_Write(unsigned char dat);
unsigned char I2C_Read();
 #define EEPROM_ID 0xa0
void delay_ms(unsigned int ms_count);
void I2C_NoAck();
void I2C_Clock();
void delay_us(unsigned int us_count);
void msdelay(unsigned int value);
void emerg_bell();




#define DS1307_ID 0xD0
#define SEC 0x00
#define MIN 0x01
#define HOUR 0x02
#define DAY 0x03
#define DATE 0x04
#define MONTH 0x05
#define YEAR 0x06
#define TUESDAY 5
#define ctrl 0x07



DS1307_get(unsigned char);
void DS1307_settime(unsigned char, unsigned char, unsigned char);
void DS1307_setdate(unsigned char, unsigned char, unsigned char,unsigned char);
Send2lcd(unsigned char);
void Rtc_Write(unsigned char,unsigned char);
Rtc_Read(unsigned char);
void Rtc_rd_wr_sub();
void Rtc_Init();
void Rtc_Start();
void Rtc_Tx();
void Rtc_Rx();
void Rtc_Stop();
void Rtc_Ack();
void disp();


unsigned int Rtc_add_wr,Rtc_add_rd;
unsigned char d_rtc,datain_rtc,in_rtc,temp_rtc,dat_rtc,flag_rtc;

unsigned char i,j,a[10],cur=0,cur1=0;
unsigned char sec,hour,min,date,day,month,year,sec1,hour1,min1,sec2,hour2,min2,hh,mm,ss,dd,mn,yy,ahour,amin,asec,amin1,ahour1,ahour2,amin2,ahour3,amin3;
unsigned char amin4,ahour4,ahour5,amin5,amin6,ahour6,ahour7,amin7,ahour8,amin8,ahour9,amin9,amin10,ahour10,ahour11,amin11,ahour12,amin12,ahour13,amin13,ahour14,amin14,ahour15,amin15,ahour16,amin16,ahour17,amin17; 

unsigned char count[8]={0x82,0x85,0x8a,0x8d,0xc2,0xc5,0xca,0xcd,};   ///0x8a changed

unsigned char count1[6]={0x86,0x89,0xc6,0xc9,0xc3,0xc6};   ///0x8a changed

unsigned char rly_hex(unsigned char tt)
{
if(tt>59)
tt+=36;
else if(tt>49)
tt+=30;
else if(tt>39)
tt+=24;
else if(tt>29)
tt+=18;
else if(tt>19)
tt+=12;
else if(tt>9)
tt+=6;
return(tt);
} 

void all_disp()
	
{


sec = DS1307_get(SEC);
min = DS1307_get(MIN);
hour = DS1307_get(HOUR);
date = DS1307_get(DATE);
day = DS1307_get(DAY);
month = DS1307_get(MONTH);
year = DS1307_get(YEAR);
	
sec=Send2lcd(sec);
min=Send2lcd(min);
hour=Send2lcd(hour);
day=Send2lcd(day);
	
date=Send2lcd(date);
year=Send2lcd(year);
month=Send2lcd(month);
	//hour_mode();
Lcd8_decimal2(0xc6,hour);
Lcd8_Write(0xc8,'.');
Lcd8_decimal2(0xc9,min);
Lcd8_Write(0xcb,'.');
Lcd8_decimal2(0xcc,sec);

	
	Lcd8_decimal2(0x82,date);
Lcd8_Write(0x84,'-');
Lcd8_decimal2(0x85,month);
Lcd8_Write(0x87,'-');
Lcd8_Display(0x88,"20 ",2);

Lcd8_decimal2(0x8a,year);

//Lcd8_decimal2(0x8d,day);


Seg8_decimal2(min);
Led8decimal2(hour);



}
void main()
{


Lcd8_Init();
Lcd8_Display(0x80,"RTC TESTING: ",12);
Delay(65000);
Delay(65000);
Lcd8_Command(0x01);
Rtc_Init();
	puls();


//DS1307_setdate(0x04,0x11,0x11);
//DS1307_settime(0x16,0x00,0x00);

while(1)
	
{

	

all_disp();
//disp();
	display_day();

if(day==0x06)
alarm_chk2();
else
alarm_chk1();

if(!set)
{
Delay(65000);
Delay(65000);


alarm_set1();
alarm_set2();
alarm_set3();
alarm_set4();
alarm_set5();
alarm_set6();
alarm_set7();
alarm_set8();
alarm_set9();
alarm_set10();
alarm_set11();
alarm_set12();
alarm_set13();
alarm_set14();
alarm_set15();
alarm_set16();
alarm_set17();
alarm_set18();
	time_set();


 set_date();



}
}
}
void emerg_bell()
{
}

void no_op()

{
	
}
void hour_mode()
	
{
	if(hour==13)
		hour=1;
	d=1;
		if(hour==14)
		hour=2;
	if(hour==15)
		hour=3;
	if(hour==16)
		hour=4;
	if(hour==17)
		hour=5;
	if(hour==18)
		hour=6;
	if(hour==19)
		hour=7;
	if(hour==20)
		hour=8;
	if(hour==21)
		hour=9;
	if(hour==22)
		hour=10;
	if(hour==23)
		hour=11;
	if(hour==24)
		hour=12;

}

void puls()
	
{
	Rtc_Start();

Rtc_Write(0x07,0x10); /* Write date on RAM address 04H */
	

Rtc_Stop(); /* Stop i2c bus */
}

void no_puls()
{
Rtc_Start();

Rtc_Write(0x07,0x00); /* Write date on RAM address 04H */
	

Rtc_Stop(); /* Stop i2c bus */
}


void display_day()
{

 if(day==0x01)
 
Lcd8_Display(0xc1,"SUN    ",3);

 if(day==0x02)

Lcd8_Display(0xc1,"MON    ",3);
 if(day==0x03)

Lcd8_Display(0xc1,"TUE   ",3);
 if(day==0x04)

Lcd8_Display(0xc1,"WED ",3);
 if(day==0x05)

Lcd8_Display(0xc1,"THU  ",3);
 if(day==0x06)

Lcd8_Display(0xc1,"FRI    ",3);
 if(day==0x07)

Lcd8_Display(0xc1,"SAT  ",3);

}


void set_date()

{
	buz_on();

Lcd8_Command(0x01);

	
all_disp();
	Lcd8_decimal2(0x8d,day);
cur=0;
while(set)
{
	
	Lcd8_Command(0x0f);
Lcd8_Command(count[cur]);

if(mov==0)
{
while(!mov);
cur++;
			buz_on();

if(cur==4)
cur=0;
}


else if(count[cur]==0x82)
{
if(inc==0)
{
while(inc==0);
date++;
buz_on();
Lcd8_decimal2(count[cur],date);

if(date>=31)
date=0;
}

else if(dec==0)
{
while(!dec);
date--;
buz_on();

if(date==0xff)
date=99;
}

}

else if(count[cur]==0x85)
{
if(inc==0)
{
while(inc==0);
month++;
	buz_on();

Lcd8_decimal2(count[cur],month);


if(month>=12)
month=0;
}

else if(dec==0)
{
while(!dec);
month--;
	buz_on();

if(month==0xff)
month=99;
}

}


else if(count[cur]==0x8a)
{
if(inc==0)
{
while(!inc);
year++;
	buz_on();

	Lcd8_decimal2(count[cur],year);

if(year>99)
year=0;
}
else if(dec==0)
{
while(!dec);
year--;
	buz_on();

if(year==0xff)
year=99;
}
}



else if(count[cur]==0x8d)
{
if(inc==0)
{
while(!inc);
day++;
	buz_on();

 //Lcd8_Command(0x01);


	display_day();

	Lcd8_decimal2(count[cur],day);

if(day>6)
day=0;
}
else if(dec==0)
{
while(!dec);
day--;
	buz_on();

if(day==0xff)
day=7;
}
}


}
dd=dec_hex(date);
mn=dec_hex(month);
yy=dec_hex(year);
									
day=dec_hex(day);



DS1307_setdate(dd,mn,yy,day); 

Lcd8_Command(0x0c);
puls();


}



void buz_on()
{
buz=0;
  Delay(6500);
buz=1;
	
}


	void time_set()

{	

	buz_on();

 Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
 Lcd8_Display(0x84,"Set Time",8);


cur=1;
while(set)


{

if(mov==0)
{
while(!mov);
cur++;
		buz_on();

if(cur==2)
cur=0;
}


else if(count[cur]==0x82)
{
if(inc==0)
{
while(inc==0);
hour++;
		buz_on();
	Led8decimal2(hour);


if(hour>=25)
hour=0;
}




else if(dec==0)
{
while(!dec);
hour--;
		buz_on();

	Led8decimal2(hour);


if(hour==0)
hour=24;
}

}

else if(count[cur]==0x85)
{
if(inc==0)
{
while(inc==0);
min++;
		buz_on();

Seg8_decimal2(min);

if(min>=60)
min=0;
}

else if(dec==0)
{
while(!dec);
min--;
		buz_on();

	Seg8_decimal2(min);

if(min==0xff)
min=31;
}

}


}
									


hh=rly_hex(hour);
mm=rly_hex(min);

DS1307_settime(hh,mm,ss);

}
	

	void blink()
	{

	e4=0;
	e3=0;
P3=0xff;
e4=1;	
e3=1;
		  Delay(6500);
Led8decimal2(hour);

	}
	
	














void alarm_set1()
	
{
	no_puls();

 ahour=EEPROM_ReadByte(0x01);
 amin=EEPROM_ReadByte(0x02);
 ahour1=EEPROM_ReadByte(0x03);
 amin1=EEPROM_ReadByte(0x04);
Delay(10000);
	buz_on();


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
 Lcd8_Display(0x84,"NOW set",7);
 Lcd8_Display(0xc0,"Regular schedule",17);
 Delay(65000);
 Lcd8_Command(0x01);
 Lcd8_Display(0xc0,"Long bell times",15);
  Delay(65000);
  Delay(65000);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"LB1)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour);
  Lcd8_decimal2(0x89,amin);
  Lcd8_Display(0xc2,"LB2)",4);
  Lcd8_decimal2(0xc6,ahour1);
  Lcd8_decimal2(0xc9,amin1);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour++;
	buz_on();

if(ahour>=24)
ahour=0;
Lcd8_decimal2(count1[cur1],ahour);
}

else if(dec==0)
{
while(!dec);
ahour--;
	buz_on();

Lcd8_decimal2(count1[cur1],ahour);


if(ahour==0)
ahour=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin++;
	buz_on();

if(amin>=60)
amin=0;
Lcd8_decimal2(count1[cur1],amin);
}

else if(dec==0)
{
while(!dec);
amin--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin);


if(amin==0)
amin=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour1++;
	buz_on();

if(ahour1>=60)
ahour1=0;
Lcd8_decimal2(count1[cur1],ahour1);
}

else if(dec==0)
{
while(!dec);
ahour1--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour1);


if(ahour1==0)
ahour1=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin1++;
	buz_on();

if(amin1>=60)
amin1=0;
Lcd8_decimal2(count1[cur1],amin1);
}

else if(dec==0)
{
while(!dec);
amin1--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin1);


if(amin1==0)
amin1=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(65000);Delay(65000);

 EEPROM_WriteByte(0x01, ahour);
 EEPROM_WriteByte(0x02, amin);
 EEPROM_WriteByte(0x03, ahour1);
 EEPROM_WriteByte(0x04, amin1);

 Lcd8_Command(0x01);	                                       

}



void alarm_set2()
	
{
 ahour2=EEPROM_ReadByte(0x05);
 amin2=EEPROM_ReadByte(0x06);
 ahour3=EEPROM_ReadByte(0x07);
 amin3=EEPROM_ReadByte(0x08);

	buz_on();
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"LB3)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour2);
  Lcd8_decimal2(0x89,amin2);
  Lcd8_Display(0xc2,"LB4)",4);
  Lcd8_decimal2(0xc6,ahour3);
  Lcd8_decimal2(0xc9,amin3);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour2++;
	buz_on();

if(ahour2>=24)
ahour2=0;
Lcd8_decimal2(count1[cur1],ahour2);
}

else if(dec==0)
{
while(!dec);
ahour2--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour2);


if(ahour2==0)
ahour2=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin2++;
	buz_on();

if(amin2>=60)
amin2=0;
Lcd8_decimal2(count1[cur1],amin2);
}

else if(dec==0)
{
while(!dec);
amin2--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin2);


if(amin2==0)
amin2=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour3++;
	buz_on();

if(ahour1>=60)
ahour3=0;
Lcd8_decimal2(count1[cur1],ahour3);
}

else if(dec==0)
{
while(!dec);
ahour3--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour3);


if(ahour3==0)
ahour3=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin3++;
	buz_on();

if(amin3>=60)
amin3=0;
Lcd8_decimal2(count1[cur1],amin3);
}

else if(dec==0)
{
while(!dec);
amin3--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin3);


if(amin3==0)
amin3=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(65000);Delay(65000);

 EEPROM_WriteByte(0x05, ahour2);
 EEPROM_WriteByte(0x06, amin2);
 EEPROM_WriteByte(0x07, ahour3);
 EEPROM_WriteByte(0x08, amin3);

 Lcd8_Command(0x01);	                                       

}


void alarm_set3()
	
{
 ahour4=EEPROM_ReadByte(0x09);
 amin4=EEPROM_ReadByte(0x10);
 ahour5=EEPROM_ReadByte(0x11);
 amin5=EEPROM_ReadByte(0x12);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"LB5)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour4);
  Lcd8_decimal2(0x89,amin4);
  Lcd8_Display(0xc2,"LB6)",4);
  Lcd8_decimal2(0xc6,ahour5);
  Lcd8_decimal2(0xc9,amin5);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour4++;
	buz_on();

if(ahour4>=24)
ahour4=0;
Lcd8_decimal2(count1[cur1],ahour4);
}

else if(dec==0)
{
while(!dec);
ahour4--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour4);


if(ahour4==0)
ahour4=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin4++;
	buz_on();

if(amin2>=60)
amin4=0;
Lcd8_decimal2(count1[cur1],amin4);
}

else if(dec==0)
{
while(!dec);
amin4--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin4);


if(amin2==0)
amin4=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour5++;
	buz_on();

if(ahour5>=60)
ahour5=0;
Lcd8_decimal2(count1[cur1],ahour5);
}

else if(dec==0)
{
while(!dec);
ahour5--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour5);


if(ahour5==0)
ahour5=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin5++;
	buz_on();

if(amin5>=60)
amin5=0;
Lcd8_decimal2(count1[cur1],amin5);
}

else if(dec==0)
{
while(!dec);
amin5--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin5);


if(amin5==0)
amin5=60;

}

}

}


Lcd8_Command(0x0c);
//Delay(65000);Delay(65000);

 EEPROM_WriteByte(0x09, ahour4);
 EEPROM_WriteByte(0x10, amin4);
 EEPROM_WriteByte(0x11, ahour5);
 EEPROM_WriteByte(0x12, amin5);

 Lcd8_Command(0x01);	                                       

}


void alarm_set4()
	
{
 ahour6=EEPROM_ReadByte(0x13);
 amin6=EEPROM_ReadByte(0x14);
 ahour7=EEPROM_ReadByte(0x15);
 amin7=EEPROM_ReadByte(0x16);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);
 Lcd8_Command(0x01);
 Lcd8_Display(0xc0,"short bell times",16);

	Lcd8_Command(0x0f);
Delay(65000);Delay(65000);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB1)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour6);
  Lcd8_decimal2(0x89,amin6);
  Lcd8_Display(0xc2,"SB2)",6);
  Lcd8_decimal2(0xc6,ahour7);
  Lcd8_decimal2(0xc9,amin7);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour6++;
	buz_on();

if(ahour6>=26)
ahour6=0;
Lcd8_decimal2(count1[cur1],ahour6);
}

else if(dec==0)
{
while(!dec);
ahour6--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour6);


if(ahour6==0)
ahour6=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin6++;
	buz_on();

if(amin6>=60)
amin6=0;
Lcd8_decimal2(count1[cur1],amin6);
}

else if(dec==0)
{
while(!dec);
amin6--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin6);


if(amin6==0)
amin6=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour7++;
	buz_on();

if(ahour7>=60)
ahour7=0;
Lcd8_decimal2(count1[cur1],ahour7);
}

else if(dec==0)
{
while(!dec);
ahour7--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour7);


if(ahour7==0)
ahour7=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin7++;
	buz_on();

if(amin7>=60)
amin7=0;
Lcd8_decimal2(count1[cur1],amin7);
}

else if(dec==0)
{
while(!dec);
amin7--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin7);


if(amin7==0)
amin7=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x13, ahour6);
 EEPROM_WriteByte(0x14, amin6);
 EEPROM_WriteByte(0x15, ahour7);
 EEPROM_WriteByte(0x16, amin7);

 Lcd8_Command(0x01);	                                       

}





void alarm_set5()
	
{
 ahour8=EEPROM_ReadByte(0x17);
 amin8=EEPROM_ReadByte(0x18);
 ahour9=EEPROM_ReadByte(0x19);
 amin9=EEPROM_ReadByte(0x20);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB3)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour8);
  Lcd8_decimal2(0x89,amin8);
  Lcd8_Display(0xc2,"SB4)",6);
  Lcd8_decimal2(0xc6,ahour9);
  Lcd8_decimal2(0xc9,amin9);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour8++;
	buz_on();

if(ahour8>=26)
ahour8=0;
Lcd8_decimal2(count1[cur1],ahour8);
}

else if(dec==0)
{
while(!dec);
ahour8--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour8);


if(ahour8==0)
ahour8=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin8++;
	buz_on();

if(amin8>=60)
amin8=0;
Lcd8_decimal2(count1[cur1],amin8);
}

else if(dec==0)
{
while(!dec);
amin8--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin8);


if(amin8==0)
amin8=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour9++;
	buz_on();

if(ahour9>=60)
ahour9=0;
Lcd8_decimal2(count1[cur1],ahour9);
}

else if(dec==0)
{
while(!dec);
ahour9--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour9);


if(ahour9==0)
ahour9=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin9++;
	buz_on();

if(amin9>=60)
amin9=0;
Lcd8_decimal2(count1[cur1],amin9);
}

else if(dec==0)
{
while(!dec);
amin9--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin9);


if(amin9==0)
amin9=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x17, ahour8);
 EEPROM_WriteByte(0x18, amin8);
 EEPROM_WriteByte(0x19, ahour9);
 EEPROM_WriteByte(0x20, amin9);

 Lcd8_Command(0x01);	                                       

}




void alarm_set6()
	
{
 ahour10=EEPROM_ReadByte(0x21);
 amin10=EEPROM_ReadByte(0x22);
 ahour11=EEPROM_ReadByte(0x23);
 amin11=EEPROM_ReadByte(0x24);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB5)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour10);
  Lcd8_decimal2(0x89,amin10);
  Lcd8_Display(0xc2,"SB6)",6);
  Lcd8_decimal2(0xc6,ahour11);
  Lcd8_decimal2(0xc9,amin11);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour10++;
	buz_on();

if(ahour10>=26)
ahour10=0;
Lcd8_decimal2(count1[cur1],ahour10);
}

else if(dec==0)
{
while(!dec);
ahour10--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour10);


if(ahour10==0)
ahour10=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin10++;
	buz_on();

if(amin10>=60)
amin10=0;
Lcd8_decimal2(count1[cur1],amin10);
}

else if(dec==0)
{
while(!dec);
amin10--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin10);


if(amin10==0)
amin10=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour11++;
	buz_on();

if(ahour11>=60)
ahour11=0;
Lcd8_decimal2(count1[cur1],ahour11);
}

else if(dec==0)
{
while(!dec);
ahour11--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour11);


if(ahour11==0)
ahour11=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin11++;
	buz_on();

if(amin11>=60)
amin11=0;
Lcd8_decimal2(count1[cur1],amin11);
}

else if(dec==0)
{
while(!dec);
amin11--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin11);


if(amin11==0)
amin11=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x21, ahour10);
 EEPROM_WriteByte(0x22, amin10);
 EEPROM_WriteByte(0x23, ahour11);
 EEPROM_WriteByte(0x24, amin11);

 Lcd8_Command(0x01);	                                       

}


void alarm_set7()
	
{
 ahour12=EEPROM_ReadByte(0x25);
 amin12=EEPROM_ReadByte(0x26);
 ahour13=EEPROM_ReadByte(0x27);
 amin13=EEPROM_ReadByte(0x28);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB7)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour12);
  Lcd8_decimal2(0x89,amin12);
  Lcd8_Display(0xc2,"SB8)",6);
  Lcd8_decimal2(0xc6,ahour13);
  Lcd8_decimal2(0xc9,amin13);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour12++;
	buz_on();

if(ahour12>=26)
ahour12=0;
Lcd8_decimal2(count1[cur1],ahour12);
}

else if(dec==0)
{
while(!dec);
ahour12--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour12);


if(ahour12==0)
ahour12=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin12++;
	buz_on();

if(amin2>=60)
amin12=0;
Lcd8_decimal2(count1[cur1],amin12);
}

else if(dec==0)
{
while(!dec);
amin12--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin12);


if(amin2==0)
amin12=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour13++;
	buz_on();

if(ahour13>=60)
ahour13=0;
Lcd8_decimal2(count1[cur1],ahour13);
}

else if(dec==0)
{
while(!dec);
ahour13--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour13);


if(ahour13==0)
ahour13=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin13++;
	buz_on();

if(amin13>=60)
amin13=0;
Lcd8_decimal2(count1[cur1],amin13);
}

else if(dec==0)
{
while(!dec);
amin13--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin13);


if(amin13==0)
amin13=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x25, ahour12);
 EEPROM_WriteByte(0x26, amin12);
 EEPROM_WriteByte(0x27, ahour13);
 EEPROM_WriteByte(0x28, amin13);

 Lcd8_Command(0x01);	                                       

}




void alarm_set8()
	
{
 ahour14=EEPROM_ReadByte(0x29);
 amin14=EEPROM_ReadByte(0x30);
 ahour15=EEPROM_ReadByte(0x31);
 amin15=EEPROM_ReadByte(0x32);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB9)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour14);
  Lcd8_decimal2(0x89,amin14);
  Lcd8_Display(0xc1,"SB10)",5);
  Lcd8_decimal2(0xc6,ahour15);
  Lcd8_decimal2(0xc9,amin15);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour14++;
	buz_on();

if(ahour14>=26)
ahour14=0;
Lcd8_decimal2(count1[cur1],ahour14);
}

else if(dec==0)
{
while(!dec);
ahour14--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour14);


if(ahour14==0)
ahour14=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin14++;
	buz_on();

if(amin2>=60)
amin14=0;
Lcd8_decimal2(count1[cur1],amin14);
}

else if(dec==0)
{
while(!dec);
amin14--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin14);


if(amin2==0)
amin14=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour15++;
	buz_on();

if(ahour15>=60)
ahour15=0;
Lcd8_decimal2(count1[cur1],ahour15);
}

else if(dec==0)
{
while(!dec);
ahour15--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour15);


if(ahour15==0)
ahour15=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin15++;
	buz_on();

if(amin15>=60)
amin15=0;
Lcd8_decimal2(count1[cur1],amin15);
}

else if(dec==0)
{
while(!dec);
amin15--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin15);


if(amin15==0)
amin15=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x29, ahour14);
 EEPROM_WriteByte(0x30, amin14);
 EEPROM_WriteByte(0x31, ahour15);
 EEPROM_WriteByte(0x32, amin15);

 Lcd8_Command(0x01);	                                       

}

void alarm_set9()
	
{
 ahour16=EEPROM_ReadByte(0x33);
 amin16=EEPROM_ReadByte(0x34);
 ahour17=EEPROM_ReadByte(0x35);
 amin17=EEPROM_ReadByte(0x36);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x81,"SB11)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour16);
  Lcd8_decimal2(0x89,amin16);
  Lcd8_Display(0xc1,"SB12)",6);
  Lcd8_decimal2(0xc6,ahour17);
  Lcd8_decimal2(0xc9,amin17);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour16++;
	buz_on();

if(ahour16>=26)
ahour16=0;
Lcd8_decimal2(count1[cur1],ahour16);
}

else if(dec==0)
{
while(!dec);
ahour16--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour16);


if(ahour16==0)
ahour16=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin16++;
	buz_on();

if(amin2>=60)
amin16=0;
Lcd8_decimal2(count1[cur1],amin16);
}

else if(dec==0)
{
while(!dec);
amin16--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin16);


if(amin16==0)
amin16=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour17++;
	buz_on();

if(ahour17>=60)
ahour17=0;
Lcd8_decimal2(count1[cur1],ahour17);
}

else if(dec==0)
{
while(!dec);
ahour17--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour17);


if(ahour17==0)
ahour17=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin17++;
	buz_on();

if(amin17>=60)
amin17=0;
Lcd8_decimal2(count1[cur1],amin17);
}

else if(dec==0)
{
while(!dec);
amin17--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin17);


if(amin17==0)
amin17=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x33, ahour16);
 EEPROM_WriteByte(0x34, amin16);
 EEPROM_WriteByte(0x35, ahour17);
 EEPROM_WriteByte(0x36, amin17);

 Lcd8_Command(0x01);	                                       

}







void alarm_set10()
	
{
 ahour=EEPROM_ReadByte(0x37);
 amin=EEPROM_ReadByte(0x38);
 ahour1=EEPROM_ReadByte(0x39);
 amin1=EEPROM_ReadByte(0x40);
Delay(10000);
	buz_on();


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
 Lcd8_Display(0x84,"NOW set",7);
 Lcd8_Display(0xc0,"Friday schedule",16);
 Delay(65000);
 Lcd8_Command(0x01);
 Lcd8_Display(0xc0,"Long bell times",15);
  Delay(65000);
  Delay(65000);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"LB1)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour);
  Lcd8_decimal2(0x89,amin);
  Lcd8_Display(0xc2,"LB2)",4);
  Lcd8_decimal2(0xc6,ahour1);
  Lcd8_decimal2(0xc9,amin1);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour++;
	buz_on();

if(ahour>=24)
ahour=0;
Lcd8_decimal2(count1[cur1],ahour);
}

else if(dec==0)
{
while(!dec);
ahour--;
	buz_on();

Lcd8_decimal2(count1[cur1],ahour);


if(ahour==0)
ahour=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin++;
	buz_on();

if(amin>=60)
amin=0;
Lcd8_decimal2(count1[cur1],amin);
}

else if(dec==0)
{
while(!dec);
amin--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin);


if(amin==0)
amin=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour1++;
	buz_on();

if(ahour1>=60)
ahour1=0;
Lcd8_decimal2(count1[cur1],ahour1);
}

else if(dec==0)
{
while(!dec);
ahour1--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour1);


if(ahour1==0)
ahour1=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin1++;
	buz_on();

if(amin1>=60)
amin1=0;
Lcd8_decimal2(count1[cur1],amin1);
}

else if(dec==0)
{
while(!dec);
amin1--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin1);


if(amin1==0)
amin1=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(65000);Delay(65000);

 EEPROM_WriteByte(0x37, ahour);
 EEPROM_WriteByte(0x38, amin);
 EEPROM_WriteByte(0x39, ahour1);
 EEPROM_WriteByte(0x40, amin1);

 Lcd8_Command(0x01);	                                       

}



void alarm_set11()
	
{
 ahour2=EEPROM_ReadByte(0x41);
 amin2=EEPROM_ReadByte(0x42);
 ahour3=EEPROM_ReadByte(0x43);
 amin3=EEPROM_ReadByte(0x44);

	buz_on();
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"LB3)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour2);
  Lcd8_decimal2(0x89,amin2);
  Lcd8_Display(0xc2,"LB4)",4);
  Lcd8_decimal2(0xc6,ahour3);
  Lcd8_decimal2(0xc9,amin3);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour2++;
	buz_on();

if(ahour2>=24)
ahour2=0;
Lcd8_decimal2(count1[cur1],ahour2);
}

else if(dec==0)
{
while(!dec);
ahour2--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour2);


if(ahour2==0)
ahour2=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin2++;
	buz_on();

if(amin2>=60)
amin2=0;
Lcd8_decimal2(count1[cur1],amin2);
}

else if(dec==0)
{
while(!dec);
amin2--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin2);


if(amin2==0)
amin2=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour3++;
	buz_on();

if(ahour1>=60)
ahour3=0;
Lcd8_decimal2(count1[cur1],ahour3);
}

else if(dec==0)
{
while(!dec);
ahour3--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour3);


if(ahour3==0)
ahour3=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin3++;
	buz_on();

if(amin3>=60)
amin3=0;
Lcd8_decimal2(count1[cur1],amin3);
}

else if(dec==0)
{
while(!dec);
amin3--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin3);


if(amin3==0)
amin3=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(65000);Delay(65000);

 EEPROM_WriteByte(0x41, ahour2);
 EEPROM_WriteByte(0x42, amin2);
 EEPROM_WriteByte(0x43, ahour3);
 EEPROM_WriteByte(0x44, amin3);

 Lcd8_Command(0x01);	                                       

}


void alarm_set12()
	
{
 ahour4=EEPROM_ReadByte(0x45);
 amin4=EEPROM_ReadByte(0x46);
 ahour5=EEPROM_ReadByte(0x47);
 amin5=EEPROM_ReadByte(0x48);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"LB5)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour4);
  Lcd8_decimal2(0x89,amin4);
  Lcd8_Display(0xc2,"LB6)",4);
  Lcd8_decimal2(0xc6,ahour5);
  Lcd8_decimal2(0xc9,amin5);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour4++;
	buz_on();

if(ahour4>=24)
ahour4=0;
Lcd8_decimal2(count1[cur1],ahour4);
}

else if(dec==0)
{
while(!dec);
ahour4--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour4);


if(ahour4==0)
ahour4=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin4++;
	buz_on();

if(amin2>=60)
amin4=0;
Lcd8_decimal2(count1[cur1],amin4);
}

else if(dec==0)
{
while(!dec);
amin4--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin4);


if(amin2==0)
amin4=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour5++;
	buz_on();

if(ahour5>=60)
ahour5=0;
Lcd8_decimal2(count1[cur1],ahour5);
}

else if(dec==0)
{
while(!dec);
ahour5--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour5);


if(ahour5==0)
ahour5=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin5++;
	buz_on();

if(amin5>=60)
amin5=0;
Lcd8_decimal2(count1[cur1],amin5);
}

else if(dec==0)
{
while(!dec);
amin5--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin5);


if(amin5==0)
amin5=60;

}

}

}


Lcd8_Command(0x0c);
//Delay(65000);Delay(65000);

 EEPROM_WriteByte(0x45, ahour4);
 EEPROM_WriteByte(0x46, amin4);
 EEPROM_WriteByte(0x47, ahour5);
 EEPROM_WriteByte(0x48, amin5);

 Lcd8_Command(0x01);	                                       

}


void alarm_set13()
	
{
 ahour6=EEPROM_ReadByte(0x49);
 amin6=EEPROM_ReadByte(0x50);
 ahour7=EEPROM_ReadByte(0x51);
 amin7=EEPROM_ReadByte(0x52);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);
 Lcd8_Command(0x01);
 Lcd8_Display(0xc0,"short bell times",16);

	Lcd8_Command(0x0f);
Delay(65000);Delay(65000);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB1)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour6);
  Lcd8_decimal2(0x89,amin6);
  Lcd8_Display(0xc2,"SB2)",6);
  Lcd8_decimal2(0xc6,ahour7);
  Lcd8_decimal2(0xc9,amin7);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==4)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour6++;
	buz_on();

if(ahour6>=26)
ahour6=0;
Lcd8_decimal2(count1[cur1],ahour6);
}

else if(dec==0)
{
while(!dec);
ahour6--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour6);


if(ahour6==0)
ahour6=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin6++;
	buz_on();

if(amin2>=60)
amin6=0;
Lcd8_decimal2(count1[cur1],amin6);
}

else if(dec==0)
{
while(!dec);
amin6--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin6);


if(amin6==0)
amin6=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour7++;
	buz_on();

if(ahour7>=60)
ahour7=0;
Lcd8_decimal2(count1[cur1],ahour7);
}

else if(dec==0)
{
while(!dec);
ahour7--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour7);


if(ahour7==0)
ahour7=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin7++;
	buz_on();

if(amin7>=60)
amin7=0;
Lcd8_decimal2(count1[cur1],amin7);
}

else if(dec==0)
{
while(!dec);
amin7--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin7);


if(amin7==0)
amin7=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x49, ahour6);
 EEPROM_WriteByte(0x50, amin6);
 EEPROM_WriteByte(0x51, ahour7);
 EEPROM_WriteByte(0x52, amin7);

 Lcd8_Command(0x01);	                                       

}





void alarm_set14()
	
{
 ahour8=EEPROM_ReadByte(0x53);
 amin8=EEPROM_ReadByte(0x54);
 ahour9=EEPROM_ReadByte(0x55);
 amin9=EEPROM_ReadByte(0x56);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB3)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour8);
  Lcd8_decimal2(0x89,amin8);
  Lcd8_Display(0xc2,"SB4)",6);
  Lcd8_decimal2(0xc6,ahour9);
  Lcd8_decimal2(0xc9,amin9);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour8++;
	buz_on();

if(ahour8>=26)
ahour8=0;
Lcd8_decimal2(count1[cur1],ahour8);
}

else if(dec==0)
{
while(!dec);
ahour8--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour8);


if(ahour8==0)
ahour8=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin8++;
	buz_on();

if(amin8>=60)
amin8=0;
Lcd8_decimal2(count1[cur1],amin8);
}

else if(dec==0)
{
while(!dec);
amin8--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin8);


if(amin8==0)
amin8=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour9++;
	buz_on();

if(ahour9>=60)
ahour9=0;
Lcd8_decimal2(count1[cur1],ahour9);
}

else if(dec==0)
{
while(!dec);
ahour9--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour9);


if(ahour9==0)
ahour9=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin9++;
	buz_on();

if(amin9>=60)
amin9=0;
Lcd8_decimal2(count1[cur1],amin9);
}

else if(dec==0)
{
while(!dec);
amin9--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin9);


if(amin9==0)
amin9=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x53, ahour8);
 EEPROM_WriteByte(0x54, amin8);
 EEPROM_WriteByte(0x55, ahour9);
 EEPROM_WriteByte(0x56, amin9);

 Lcd8_Command(0x01);	                                       

}




void alarm_set15()
	
{
 ahour10=EEPROM_ReadByte(0x57);
 amin10=EEPROM_ReadByte(0x58);
 ahour11=EEPROM_ReadByte(0x59);
 amin11=EEPROM_ReadByte(0x60);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB5)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour10);
  Lcd8_decimal2(0x89,amin10);
  Lcd8_Display(0xc2,"SB6)",6);
  Lcd8_decimal2(0xc6,ahour11);
  Lcd8_decimal2(0xc9,amin11);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour10++;
	buz_on();

if(ahour10>=26)
ahour10=0;
Lcd8_decimal2(count1[cur1],ahour10);
}

else if(dec==0)
{
while(!dec);
ahour10--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour10);


if(ahour10==0)
ahour10=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin10++;
	buz_on();

if(amin10>=60)
amin10=0;
Lcd8_decimal2(count1[cur1],amin10);
}

else if(dec==0)
{
while(!dec);
amin10--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin10);


if(amin10==0)
amin10=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour11++;
	buz_on();

if(ahour11>=60)
ahour11=0;
Lcd8_decimal2(count1[cur1],ahour11);
}

else if(dec==0)
{
while(!dec);
ahour11--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour11);


if(ahour11==0)
ahour11=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin11++;
	buz_on();

if(amin11>=60)
amin11=0;
Lcd8_decimal2(count1[cur1],amin11);
}

else if(dec==0)
{
while(!dec);
amin11--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin11);


if(amin11==0)
amin11=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x57, ahour10);
 EEPROM_WriteByte(0x58, amin10);
 EEPROM_WriteByte(0x59, ahour11);
 EEPROM_WriteByte(0x60, amin11);

 Lcd8_Command(0x01);	                                       

}


void alarm_set16()
	
{
 ahour12=EEPROM_ReadByte(0x61);
 amin12=EEPROM_ReadByte(0x62);
 ahour13=EEPROM_ReadByte(0x63);
 amin13=EEPROM_ReadByte(0x64);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB7)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour12);
  Lcd8_decimal2(0x89,amin12);
  Lcd8_Display(0xc2,"SB8)",6);
  Lcd8_decimal2(0xc6,ahour13);
  Lcd8_decimal2(0xc9,amin13);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour12++;
	buz_on();

if(ahour12>=26)
ahour12=0;
Lcd8_decimal2(count1[cur1],ahour12);
}

else if(dec==0)
{
while(!dec);
ahour12--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour12);


if(ahour12==0)
ahour12=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin12++;
	buz_on();

if(amin2>=60)
amin12=0;
Lcd8_decimal2(count1[cur1],amin12);
}

else if(dec==0)
{
while(!dec);
amin12--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin12);


if(amin2==0)
amin12=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour13++;
	buz_on();

if(ahour13>=60)
ahour13=0;
Lcd8_decimal2(count1[cur1],ahour13);
}

else if(dec==0)
{
while(!dec);
ahour13--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour13);


if(ahour13==0)
ahour13=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin13++;
	buz_on();

if(amin13>=60)
amin13=0;
Lcd8_decimal2(count1[cur1],amin13);
}

else if(dec==0)
{
while(!dec);
amin13--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin13);


if(amin13==0)
amin13=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x61, ahour12);
 EEPROM_WriteByte(0x62, amin12);
 EEPROM_WriteByte(0x63, ahour13);
 EEPROM_WriteByte(0x64, amin13);

 Lcd8_Command(0x01);	                                       

}




void alarm_set17()
	
{
 ahour14=EEPROM_ReadByte(0x65);
 amin14=EEPROM_ReadByte(0x66);
 ahour15=EEPROM_ReadByte(0x67);
 amin15=EEPROM_ReadByte(0x68);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x82,"SB9)",4);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour14);
  Lcd8_decimal2(0x89,amin14);
  Lcd8_Display(0xc1,"SB10)",5);
  Lcd8_decimal2(0xc6,ahour15);
  Lcd8_decimal2(0xc9,amin15);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour14++;
	buz_on();

if(ahour14>=26)
ahour14=0;
Lcd8_decimal2(count1[cur1],ahour14);
}

else if(dec==0)
{
while(!dec);
ahour14--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour14);


if(ahour14==0)
ahour14=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin14++;
	buz_on();

if(amin2>=60)
amin14=0;
Lcd8_decimal2(count1[cur1],amin14);
}

else if(dec==0)
{
while(!dec);
amin14--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin14);


if(amin2==0)
amin14=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour15++;
	buz_on();

if(ahour15>=60)
ahour15=0;
Lcd8_decimal2(count1[cur1],ahour15);
}

else if(dec==0)
{
while(!dec);
ahour15--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour15);


if(ahour15==0)
ahour15=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin15++;
	buz_on();

if(amin15>=60)
amin15=0;
Lcd8_decimal2(count1[cur1],amin15);
}

else if(dec==0)
{
while(!dec);
amin15--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin15);


if(amin15==0)
amin15=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x65, ahour14);
 EEPROM_WriteByte(0x66, amin14);
 EEPROM_WriteByte(0x67, ahour15);
 EEPROM_WriteByte(0x68, amin15);

 Lcd8_Command(0x01);	                                       

}

void alarm_set18()
	
{
 ahour16=EEPROM_ReadByte(0x69);
 amin16=EEPROM_ReadByte(0x70);
 ahour17=EEPROM_ReadByte(0x71);
 amin17=EEPROM_ReadByte(0x72);

	buz_on();
//Delay(65000);
Delay(10000);


	Lcd8_Command(Curser_Off);

 Lcd8_Command(0x01);
	Lcd8_Command(0x0f);

 
  Lcd8_Command(0x01);
  Lcd8_Display(0x81,"SB11)",6);
	Lcd8_Display(0x88,":",1);
  	Lcd8_Display(0xc8,":",1);

  Lcd8_decimal2(0x86,ahour16);
  Lcd8_decimal2(0x89,amin16);
  Lcd8_Display(0xc1,"SB12)",6);
  Lcd8_decimal2(0xc6,ahour17);
  Lcd8_decimal2(0xc9,amin17);

cur1=0;

while(set)
{
Lcd8_Command(0x0f);
Lcd8_Command(count1[cur1]);
if(mov==0)
{
while(!mov);
cur1++;
if(cur1==6)
cur1=0;
}
else if(count1[cur1]==0x86)			                    ///1st line of lcd
{
if(inc==0)
{
while(inc==0);
ahour16++;
	buz_on();

if(ahour16>=26)
ahour16=0;
Lcd8_decimal2(count1[cur1],ahour16);
}

else if(dec==0)
{
while(!dec);
ahour16--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour16);


if(ahour16==0)
ahour16=24;
}

}
else if(count1[cur1]==0x89)
{
if(inc==0)
{
while(inc==0);
amin16++;
	buz_on();

if(amin2>=60)
amin16=0;
Lcd8_decimal2(count1[cur1],amin16);
}

else if(dec==0)
{
while(!dec);
amin16--;
		buz_on();
Lcd8_decimal2(count1[cur1],amin16);


if(amin16==0)
amin16=60;
}

}
else if(count1[cur1]==0xc6)
{
if(inc==0)
{
while(inc==0);
ahour17++;
	buz_on();

if(ahour17>=60)
ahour17=0;
Lcd8_decimal2(count1[cur1],ahour17);
}

else if(dec==0)
{
while(!dec);
ahour17--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],ahour17);


if(ahour17==0)
ahour17=24;
}

}
else if(count1[cur1]==0xc9)
{
if(inc==0)
{
while(inc==0);
amin17++;
	buz_on();

if(amin17>=60)
amin17=0;
Lcd8_decimal2(count1[cur1],amin17);
}

else if(dec==0)
{
while(!dec);
amin17--;
	buz_on();

		buz_on();
Lcd8_decimal2(count1[cur1],amin17);


if(amin17==0)
amin17=60;
}

}

}


Lcd8_Command(0x0c);
//Delay(67000);Delay(67000);

 EEPROM_WriteByte(0x69, ahour16);
 EEPROM_WriteByte(0x70, amin16);
 EEPROM_WriteByte(0x71, ahour17);
 EEPROM_WriteByte(0x72, amin17);

 Lcd8_Command(0x01);	                                       
}
















void alarm_chk1()
{
 ahour=EEPROM_ReadByte(0x01);
 amin=EEPROM_ReadByte(0x02);
 ahour1=EEPROM_ReadByte(0x03);
 amin1=EEPROM_ReadByte(0x04);
 ahour2=EEPROM_ReadByte(0x05);
 amin2=EEPROM_ReadByte(0x06);
 ahour3=EEPROM_ReadByte(0x07);
 amin3=EEPROM_ReadByte(0x08);
 ahour4=EEPROM_ReadByte(0x09);
 amin4=EEPROM_ReadByte(0x10);
 ahour5=EEPROM_ReadByte(0x11);
 amin5=EEPROM_ReadByte(0x12);
 ahour6=EEPROM_ReadByte(0x13);
 amin6=EEPROM_ReadByte(0x14);
 ahour7=EEPROM_ReadByte(0x15);
 amin7=EEPROM_ReadByte(0x16);
 ahour8=EEPROM_ReadByte(0x17);
 amin8=EEPROM_ReadByte(0x18);
 ahour9=EEPROM_ReadByte(0x19);
 amin9=EEPROM_ReadByte(0x20);
 ahour10=EEPROM_ReadByte(0x21);
 amin10=EEPROM_ReadByte(0x22);
 ahour11=EEPROM_ReadByte(0x23);
 amin11=EEPROM_ReadByte(0x24);     //0x34
 ahour12=EEPROM_ReadByte(0x25);
 amin12=EEPROM_ReadByte(0x26);
 ahour13=EEPROM_ReadByte(0x27);
 amin13=EEPROM_ReadByte(0x28);
 ahour14=EEPROM_ReadByte(0x29);
 amin14=EEPROM_ReadByte(0x30);
 ahour15=EEPROM_ReadByte(0x31);
 amin15=EEPROM_ReadByte(0x32);
 ahour16=EEPROM_ReadByte(0x33);
 amin16=EEPROM_ReadByte(0x34);



if(hour==ahour)
if(min==amin)
if(sec==asec)

	
alarm_bell_HI();
else
rly=1;

if(hour==ahour1)
if(min==amin1)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour2)
if(min==amin2)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour3)
if(min==amin3)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour4)
if(min==amin4)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour5)
if(min==amin5)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour6)
if(min==amin6)
if(sec==asec)
alarm_bell_LOW();
else
rly=1;
if(hour==ahour7)
if(min==amin7)
if(sec==asec)
alarm_bell_LOW();
else
rly=1;
if(hour==ahour8)
if(min==amin8)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour9)
if(min==amin9)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour10)
if(min==amin10)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour11)
if(min==amin11)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;

if(hour==ahour12)
if(min==amin12)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour13)
if(min==amin13)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour14)
if(min==amin14)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour15)
if(min==amin15)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour16)
if(min==amin16)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;



}

void alarm_chk2()
{
 ahour=EEPROM_ReadByte(0x35);
 amin=EEPROM_ReadByte(0x36);
 ahour1=EEPROM_ReadByte(0x37);
 amin1=EEPROM_ReadByte(0x38);
 ahour2=EEPROM_ReadByte(0x39);
 amin2=EEPROM_ReadByte(0x40);
 ahour3=EEPROM_ReadByte(0x41);
 amin3=EEPROM_ReadByte(0x42);
 ahour4=EEPROM_ReadByte(0x43);
 amin4=EEPROM_ReadByte(0x44);
 ahour5=EEPROM_ReadByte(0x45);
 amin5=EEPROM_ReadByte(0x46);
 ahour6=EEPROM_ReadByte(0x47);
 amin6=EEPROM_ReadByte(0x48);
 ahour7=EEPROM_ReadByte(0x49);
 amin7=EEPROM_ReadByte(0x50);
 ahour8=EEPROM_ReadByte(0x51);
 amin8=EEPROM_ReadByte(0x52);
 ahour9=EEPROM_ReadByte(0x53);
 amin9=EEPROM_ReadByte(0x54);
 ahour10=EEPROM_ReadByte(0x55);
 amin10=EEPROM_ReadByte(0x56);
 ahour11=EEPROM_ReadByte(0x57);
 amin11=EEPROM_ReadByte(0x58);
  ahour12=EEPROM_ReadByte(0x59);
 amin12=EEPROM_ReadByte(0x60);
 ahour13=EEPROM_ReadByte(0x61);
 amin13=EEPROM_ReadByte(0x62);
 ahour14=EEPROM_ReadByte(0x63);
 amin14=EEPROM_ReadByte(0x64);
 ahour15=EEPROM_ReadByte(0x65);
 amin15=EEPROM_ReadByte(0x66);
 ahour16=EEPROM_ReadByte(0x67);
 amin16=EEPROM_ReadByte(0x68);


 if(hour==ahour)
if(min==amin)
if(sec==asec)
alarm_bell_HI();
else
rly=1;

if(hour==ahour1)
if(min==amin1)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour2)
if(min==amin2)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour3)
if(min==amin3)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour4)
if(min==amin4)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour5)
if(min==amin5)
if(sec==asec)
alarm_bell_HI();
else
rly=1;
if(hour==ahour6)
if(min==amin6)
if(sec==asec)
alarm_bell_LOW();
else
rly=1;
if(hour==ahour7)
if(min==amin7)
if(sec==asec)
alarm_bell_LOW();
else
rly=1;
if(hour==ahour8)
if(min==amin8)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour9)
if(min==amin9)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour10)
if(min==amin10)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour11)
if(min==amin11)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;

if(hour==ahour12)
if(min==amin12)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour13)
if(min==amin13)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour14)
if(min==amin14)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour15)
if(min==amin15)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;
if(hour==ahour16)
if(min==amin16)
if(sec==asec)
alarm_bell_LOW();

else
rly=1;


}


void alarm_bell_HI()
{
Lcd8_Command(0x01);

	Lcd8_Display(0xc0,"Bell ringing.. ",14);

rly=0;
 Delay(65000);Delay(65000);
 Delay(65000);Delay(65000);
 Delay(65000);Delay(65000);

rly=1;
		Lcd8_Command(0x01);



}

void alarm_bell_LOW()
{
rly=0;
 Delay(65000);
 Delay(65000);

rly=1;
	

}












void Lcd8_Init()
{
Lcd8_Command(0x38); //to select function set
Lcd8_Command(0x06); //entry mode set
Lcd8_Command(0x0c); //display on
Lcd8_Command(0x01); //clear display
}

void Lcd8_Command(unsigned char com)
{
Data_Port=com;
Lcd_en=1;
Lcd_rs=0;
//Lcd_rw=0;

Delay(125);
Lcd_en=0;
Delay(125);
}

void Lcd8_Write(unsigned char com,unsigned char lr)
{
Lcd8_Command(com);
Data_Port=lr; // Data 
Lcd_en=Lcd_rs=1;
//Lcd_rw=0;
Delay(125);
Lcd_en=0;
Delay(125);
}

void Lcd8_Display(unsigned char com,const unsigned char *word,unsigned int n)
{
unsigned char Lcd_i;
for(Lcd_i=0;Lcd_i<n;Lcd_i++)
{ 
Lcd8_Write(com+Lcd_i,word[Lcd_i]);
}
}

void Lcd8_decimal2(unsigned char com,unsigned char val)
{
unsigned int Lcd_hr,Lcd_t,Lcd_o;

Lcd_hr=val%100;
Lcd_t=Lcd_hr/10;
Lcd_o=Lcd_hr%10;

Lcd8_Write(com,Lcd_t+0x30);
Lcd8_Write(com+1,Lcd_o+0x30);
}



void Delay(unsigned int del)
{
while(del--);
}



void Seg8_decimal2(min)

{
unsigned int Lcd_hr,Lcd_t,Lcd_o;

Lcd_hr=min%100;
Lcd_t=Lcd_hr/10;
Lcd_o=Lcd_hr%10;
e5=0;
P3=Lcd_t+0x30;
e5=1;
e6=0;
P3=Lcd_o+0x30;
e6=1;

}







void Led8decimal2(hour)
{
unsigned int Lcd_hr,Lcd_t,Lcd_o;

Lcd_hr=hour%100;
Lcd_t=Lcd_hr/10;
Lcd_o=Lcd_hr%10;
e4=0;
P3=Lcd_t+0x30;
e4=1;
e3=0;
P3=Lcd_o+0x30;
e3=1;
}


/*********************************LCD HEADER FILE END*************************************/



/*********************************RTC HEADER FILE START*********************************/


DS1307_get(unsigned char addr)
{
unsigned char ret;

Rtc_Start(); 
ret = Rtc_Read(addr);
Rtc_Stop();

return ret;
}

void DS1307_settime(unsigned char hh, unsigned char mm, unsigned char ss)
{
Rtc_Start(); 

Rtc_Write(0x00,ss); /* Write sec on RAM address 00H */
Rtc_Write(0x01,mm); /* Write min on RAM address 01H */
Rtc_Write(0x02,hh); /* Write hour on RAM address 02H */

Rtc_Stop(); /* Stop i2c bus */
}


void DS1307_setdate(unsigned char dd, unsigned char mm, unsigned char yy,unsigned char day)
{
Rtc_Start();

Rtc_Write(0x04,dd); /* Write date on RAM address 04H */
Rtc_Write(0x05,mm); /* Write month on RAM address 05H */
Rtc_Write(0x06,yy); /* Write year on RAM address 06H */
	Rtc_Write(0x03,day); /* Write year on RAM address 03H */


Rtc_Stop(); /* Stop i2c bus */
}


Send2lcd(unsigned char value)
{
unsigned char buf1,buf2,buf = 0;

buf1 = value & 0xF0; /* Filter for high byte */
buf1 = (buf1>>4); /* Convert to ascii code */
buf2 = value & 0x0F; /* Filter for low byte */
buf=(buf1*10)+buf2;

return buf;
}


void Rtc_Init()//lower order 256 bytes of the chip
{
Rtc_add_wr=0xd0;
Rtc_add_rd=0xd1;
}


void Rtc_Write(unsigned char zig,unsigned char zag)// program to write to EEPROM
{
dat_rtc=zig;
temp_rtc=zag;
Rtc_rd_wr_sub();
above:
d_rtc=temp_rtc;
Rtc_Tx();
if (CY==1)goto above;
CY=0;
Rtc_Stop();
}


Rtc_Read(unsigned char zig)// program to read from EEPROM
{
dat_rtc=zig;
Rtc_rd_wr_sub();
Rtc_Start();
be:
d_rtc=Rtc_add_rd; // 0xd1 =Rtc_add_rd
Rtc_Tx();
if(CY==1)goto be;
Rtc_Rx();
Rtc_Ack();
CY=0;
Rtc_Stop();
return(datain_rtc);
}


void Rtc_Start()// must for any operation on EEPROM
{
sda_rtc=1;
scl_rtc=1;
sda_rtc=0;
scl_rtc=0;
}


void Rtc_Stop()// this is similar to the START operation whereas this should be performed after the completion of any operation
{
sda_rtc=0;
scl_rtc=1;
sda_rtc=1;
}


void Rtc_Tx()// program to send the device address, read/write address,data to be written
{
signed char i_rtc;
for(i_rtc=7;i_rtc>=0;i_rtc--)// should necessarily be initialised as signed char.
{
CY=(d_rtc>>i_rtc)&0x01;
sda_rtc=CY;
scl_rtc=1;// clock is essential inorder to write or read
scl_rtc=0;// clk should be alternated
}
sda_rtc=1;
scl_rtc=1;
CY=sda_rtc;
scl_rtc=0;
}


void Rtc_Rx()// program read the data from the EEPROM
{
unsigned char l_rtc;
sda_rtc=1;
for (l_rtc=0;l_rtc<=7;l_rtc++)
{
scl_rtc=1;
in_rtc=in_rtc<<1;
in_rtc|=sda_rtc;
scl_rtc=0;
}
datain_rtc=in_rtc;
in_rtc=0;
}


void Rtc_Ack()// this is to intimate the EEPROM that the read operation is over
{
sda_rtc=1;
scl_rtc=1;
scl_rtc=0;
}


void Rtc_rd_wr_sub()// this routine will be used by both the read & write operations to send the device address & the address at which the corresponding action is to be taken
{
Rtc_Start();
here1:
d_rtc=Rtc_add_wr;// 0xd0 device address is passed
Rtc_Tx();
if(CY==1)goto here1;
again1:
d_rtc=dat_rtc;// the address from which data is to be read/written is to be passed
Rtc_Tx();
if(CY==1)goto again1;
}

void EEPROM_WriteByte(unsigned char eeprom_Address, unsigned char eeprom_Data)
{
 
    I2C_Start();               // Start i2c communication
    I2C_Write(EEPROM_ID);      // connect to AT2404 by sending its ID on I2c Bus
    I2C_Ack();
    I2C_Write(eeprom_Address); // Select the Specified EEPROM address of AT2404
    I2C_Ack();
    I2C_Write(eeprom_Data);    // Write the data at specified address
    I2C_Ack();
    I2C_Stop();                // Stop i2c communication after Writing the data
    delay_ms(1);            // Write operation takes max 5ms, refer At2404 datasheet        
}
 
unsigned char EEPROM_ReadByte(unsigned char eeprom_Address)
{
  unsigned char eeprom_Data;
 
    I2C_Start();               // Start i2c communication
    I2C_Write(EEPROM_ID);      // connect to AT2404(write) by sending its ID on I2c Bus
    I2C_Ack();
    I2C_Write(eeprom_Address); // Select the Specified EEPROM address of AT2404
    I2C_Ack();
 
    I2C_Start();               // Start i2c communication
    I2C_Write(0xA1);           // connect to AT2404(read) by sending its ID on I2c Bus
    I2C_Ack();
   eeprom_Data = I2C_Read();  // Read the data from specified address
    I2C_NoAck();
    I2C_Stop();                // Stop i2c communication after Reading the data
    delay_us(10);
  return eeprom_Data;          // Return the Read data
 
}
void I2C_Start()
{
    SCL = 0;        // Pull SCL low
 
    SDA = 1;        // Pull SDA High
    delay_us(1);
 
    SCL = 1;        //Pull SCL high
    delay_us(1);
 
    SDA = 0;        //Now Pull SDA LOW, to generate the Start Condition
    delay_us(1);
 
    SCL = 0;        //Finally Clear the SCL to complete the cycle
}

void I2C_Stop(void)
{
    SCL = 0;            // Pull SCL low
    delay_us(1);
 
    SDA = 0;            // Pull SDA  low
    delay_us(1);
 
    SCL = 1;            // Pull SCL High
    delay_us(1);
 
    SDA = 1;            // Now Pull SDA High, to generate the Stop Condition
}

void I2C_Ack()
{
    SDA = 0;        //Pull SDA low to indicate Positive ACK
    I2C_Clock();    //Generate the Clock
    SDA = 1;        // Pull SDA back to High(IDLE state)
}

void I2C_NoAck()
{
    SDA = 1;        //Pull SDA high to indicate Negative/NO ACK
   I2C_Clock();     // Generate the Clock  
    SCL = 1;        // Set SCL */
}

void I2C_Write(unsigned char dat)
{
    unsigned char i;
 
    for(i=0;i<8;i++)         // loop 8 times to send 1-byte of data
     {
        SDA = dat & 0x80;    // Send Bit by Bit on SDA line
        I2C_Clock();         // Generate Clock at SCL
        dat = dat<<1;
      }
        SDA = 1;                 // Set SDA at last
}
 

unsigned char I2C_Read(void)
{
    unsigned char i, dat=0x00;
 
       SDA=1;               //Make SDA as I/P
    for(i=0;i<8;i++)        // loop 8times to read 1-byte of data
     {
       delay_us(1);
        SCL = 1;            // Pull SCL High
        delay_us(1);
 
        dat = dat<<1;       //dat is Shifted each time and
        dat = dat | SDA;    //ORed with the received bit to pack into byte
 
        SCL = 0;            // Clear SCL to complete the Clock
       }
   return dat;               // Finally return the received Byte*
}
 
 void delay_ms(unsigned int ms_count)
 {
        while(ms_count!=0)
         {
            delay_us(112);   //delay_us is called to generate 1ms delay
             ms_count--;
            }
   }
 

  void delay_us(unsigned int us_count)
 {  
    while(us_count!=0)
      {
         us_count--;
       }												   
   }
 
 void I2C_Clock(void)
{
    delay_us(1);
    SCL = 1;        // Wait for Some time and Pull the SCL line High
 
    delay_us(1);        // Wait for Some time
    SCL = 0;        // Pull back the SCL line low to Generate a clock pulse
}
 

Ok IT must work just other thought can you try sunbber connection across J2 in your schematic.
 

Dear sir I am trying with snubber in parrellel with j2.one thing,I have designed relay circuit & controller circuit in same pcb.is it right?
 

it is ok to have relay and controller in same PCB with proper routing and component placing.
 

Dear sir,which value of snubber is better? & Can I connect two series conected mov's for more protection?
 

  • Like
Reactions: tapu

    tapu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top