電子時鐘+測溫+紅外遙控調(diào)時程序 作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對面交流海量資料庫查詢 收藏 void set_key(){if(key1==0){bb++;delay(8);if(key1==0){if(bb==1){while(!key1);TR0=0;write_com(0x80+0x40+13);write_com(0x0f);}if(bb==2){while(!key1);write_com(0x80+0x40+10);}if(bb==3){while(!key1);write_com(0x80+0x40+7);}if(bb==4){while(!key1);write_com(0x80+12);}if(bb==5){while(!key1);write_com(0x80+9);}if(bb==6){while(!key1);write_com(0x80+6);}if(bb==7){while(!key1);write_com(0x80+3);}if(bb==8){bb=0;while(!key1);TR0=1;write_com(0x0c);}}}if(bb==1){if(key2==0){delay(8);while(!key2);miao++;if(miao==60){miao=0;}sfm_date(13,miao);write_com(0x80+0x40+13); }if(key3==0){delay(8);while(!key3);miao--;if(miao==-1){miao=59;}sfm_date(13,miao);write_com(0x80+0x40+13); }}if(bb==2){if(key2==0){delay(8);while(!key2);fen++;if(fen==60){fen=0;}sfm_date(10,fen);write_com(0x80+0x40+10); }if(key3==0){delay(8);while(!key3);fen--;if(fen==-1){fen=59;}sfm_date(10,fen);write_com(0x80+0x40+10); }}if(bb==3){if(key2==0){delay(8);while(!key2);shi++;if(shi==24){shi=0;}sfm_date(7,shi);write_com(0x80+0x40+7); }if(key3==0){delay(8);while(!key3);shi--;if(shi==-1){shi=23;}sfm_date(7,shi);write_com(0x80+0x40+7); }}if(bb==4){if(key2==0){delay(8);dd++;while(!key2);if(dd==1){for(cc=0;cc<3;cc++){write_data(table2[cc]);}}write_com(0x80+12);if(dd==2){for(cc=0;cc<3;cc++){write_data(table3[cc]);}}write_com(0x80+12);if(dd==3){for(cc=0;cc<3;cc++){write_data(table4[cc]);}}write_com(0x80+12);if(dd==4){for(cc=0;cc<3;cc++){write_data(table5[cc]);}}write_com(0x80+12);if(dd==5){for(cc=0;cc<3;cc++){write_data(table6[cc]);}}write_com(0x80+12);if(dd==6){for(cc=0;cc<3;cc++){write_data(table7[cc]);}}write_com(0x80+12);if(dd==7){dd=0;for(cc=0;cc<3;cc++){write_data(table8[cc]);}}write_com(0x80+12);}if(key3==0){dd++;delay(8);while(!key3);if(dd==1){for(cc=0;cc<3;cc++){write_data(table8[cc]);}}write_com(0x80+12);if(dd==2){for(cc=0;cc<3;cc++){write_data(table7[cc]);}}write_com(0x80+12);if(dd==3){for(cc=0;cc<3;cc++){write_data(table6[cc]);}}write_com(0x80+12);if(dd==4){for(cc=0;cc<3;cc++){write_data(table5[cc]);}}write_com(0x80+12);if(dd==5){for(cc=0;cc<3;cc++){write_data(table4[cc]);}}write_com(0x80+12);if(dd==6){for(cc=0;cc<3;cc++){write_data(table3[cc]);}}write_com(0x80+12);if(dd==7){dd=0;for(cc=0;cc<3;cc++){write_data(table2[cc]);}}write_com(0x80+12);}}if(bb==5){if(key2==0){delay(8);while(!key2);ee++;if(ee==32){ee=1;}nyr_date1(9,ee);write_com(0x80+9); }if(key3==0){delay(8);while(!key3);ee--;if(ee==0){ee=31;}nyr_date1(9,ee);write_com(0x80+9); } }if(bb==6){if(key2==0){delay(8);while(!key2);ff++;if(ff==13){ff=1;}nyr_date1(6,ff);write_com(0x80+6); }if(key3==0){delay(8);while(!key3);ff--;if(ff==0){ff=12;}nyr_date1(6,ff);write_com(0x80+6); } }if(bb==7){if(key2==0){delay(8);while(!key2);gg++;if(gg==41){gg=11;}nyr_date1(3,gg);write_com(0x80+3); }if(key3==0){delay(8);while(!key3);gg--;if(gg==10){gg=41;}nyr_date1(3,gg);write_com(0x80+3); } }}void check_DS18B20(){dd1=chuli_dat();m=dd1/10;n=dd1%10;write_com(0x80+0x40+2);write_data(table9);write_com(0x80+0x40+3); write_data(table9[n]);}void main(){init();while(1){if(ir==0){restart:while(ir);temp=low_ir_time();if((temp<8500)||(temp>9500)) continue;temp=high_ir_time();if((temp<4000)&&(temp>5000)) continue;for(i=0;i<4;i++){for(j=0;j<8;j++){temp=low_ir_time();if((temp<200)||(temp>800)) goto restart;temp=high_ir_time();if((temp<200)||(temp>2000)) goto restart;ss[i]=ss[i]>>1;if(temp>1120){ss[i]=ss[i]|0x80;}}}if(ss[2]=~ss[3]){pp=ss[2]; }}set_key();ir_key();}}void timer0() interrupt 1{TH0=(65536-50000)/256;TL0=(65536-50000)%256;aa++;if(aa==20){aa=0;miao++;check_DS18B20();if(miao==60){miao=0;fen++;if(fen==60){fen=0;shi++;if(shi==24){shi=0;flag=1;}sfm_date(7,shi);}sfm_date(10,fen);}sfm_date(13,miao); }if(flag==1){flag=0;ee++;if(ee==32){ee=1;flag1=1;}nyr_date1(9,ee);//write_com(0x80+9);dd++;if(dd==8){dd=0;}if(dd==1){write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table2[cc]);}}write_com(0x80+12);if(dd==2){write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table3[cc]);}}//write_com(0x80+12);if(dd==3){write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table4[cc]);}}//write_com(0x80+12);if(dd==4){write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table5[cc]);}}//write_com(0x80+12);if(dd==5){write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table6[cc]);}}//write_com(0x80+12);if(dd==6){write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table7[cc]);}}//write_com(0x80+12);if(dd==7){dd=0;write_com(0x80+12);for(cc=0;cc<3;cc++){write_data(table8[cc]);}}// write_com(0x80+12);}if(flag1==1){flag1=0;ff++;if(ff==13){ff=1;flag2=1;}nyr_date1(6,ff);write_com(0x80+6); }if(flag2==1){flag2=0;gg++;if(gg==41){gg=11;}nyr_date1(3,gg);write_com(0x80+3); }} 上一頁 1 2 下一頁
評論