Objective:
- Program for the push button for set the time
Contents:
- Make a programming for push button to select the time
- Load to PIC16F887
switch(mode){
case 0: case 1:{
lcd_goto(0,0); //select first line in LCD // will show at
first line LCD
lcd_string("Time :
");
if((set==1)&(counter[0]<PULSE/2))
lcd_string(" ");
else lcd_number(hrs,10,2);
lcd_string(":");
if((set==2)&(counter[0]<PULSE/2))
lcd_string(" ");
else lcd_number(min,10,2);
lcd_string(":");
if((set==3)&(counter[0]<PULSE/2))
lcd_string(" ");
else lcd_number(sec,10,2);
lcd_string(" ");
lcd_goto(0,1); //select second line in LCD // will show at
second line LCD
lcd_string("Date :
");
if((set==4)&(counter[0]<PULSE/2))
lcd_string(" ");
else lcd_number(date,10,2);
lcd_string("/");
if((set==5)&(counter[0]<PULSE/2))
lcd_string(" ");
else lcd_number(month,10,2);
lcd_string("/");
if((set==6)&(counter[0]<PULSE/2))
lcd_string(" ");
else lcd_number(year,10,2);
lcd_string(" ");
if(mode==0){
if(button==3){
set=1;
mode++;
delay(200);}}
else if(mode==1){
switch(button){
case 1:{
mode++;
set=0;
delay(200);
break;}
if(set<6) set++;
else set=1;
delay(200);
break;}
case 4:{
switch(set){
case 1:{
if(hrs<23) hrs++;
else hrs=0;
rtc_set(2,hrs); //set hours
break;}
case 2:{
if(min<59) min++;
else min=0;
rtc_set(1,min); //set min
break;}
case 3:{
sec=0;
rtc_set(0,sec); //set sec
break;}
case 4:{
if(date<mo[month-1]) date++;
else date=1;
rtc_set(4,date); //set date
break;}
case 5:{
if(month<12) month++;
else month=1;
rtc_set(5,month); //set month
break;}
case 6:{
if(year<99) year++;
else year=0;
rtc_set(6,year); //set year
break;}
}
delay(200);
break;}
case 8:{
switch(set){
case 1:{
if(hrs>0) hrs--;
else hrs=23;
rtc_set(2,hrs); //set hours
break;}
case 2:{
if(min>0) min--;
else min=59;
rtc_set(1,min); //set min
break;}
case 3:{
sec=0;
rtc_set(0,sec); //set sec
break;}
case 4:{
if(date>1) date--;
else date=mo[month-1];
rtc_set(4,date); //set date
break;}
case 5:{
if(month>1) month--;
else month=12;
rtc_set(5,month); //set month
break;}
case 6:{
if(year>0) year--;
else year=99;
rtc_set(6,year); //set year
break;}
}
delay(200);
break;}
}
}
break;}
Conclusion:
The programming for the push button has been successful to load into PIC. For next step, i will programming for the GSM.
No comments:
Post a Comment