51單片機(jī)電子鐘制作-升級版 作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對面交流海量資料庫查詢 收藏 //溫度調(diào)整顯示if( (K1num==3)&&(K4num==0) ){TR1=0; wx1=1; P0=0x89; delay1(2); wx1=0; //H wx2=1; P0=0xBF; delay1(2); wx2=0; //-wx3=1; P0=table1[H1]; delay1(2); wx3=0; //時十位wx4=1; P0=table1[H2]; delay1(2); wx4=0; //時個位 wx5=1; P0=0xC7; delay1(2); wx5=0; //Lwx6=1; P0=0xBF; delay1(2); wx6=0; //- wx7=1; P0=table[L1]; delay1(2); wx7=0; //分十位 wx8=1; P0=table[L2]; delay1(2); wx8=0; //分個位}if( (K1num==3)&&(K4num==1) ){TR1=1; wx1=1; P0=0x89; delay1(2); wx1=0; //H wx2=1; P0=0xBF; delay1(2); wx2=0; //-if(count2<60){wx3=1; P0=table1[H1]; delay1(2); wx3=0;} //時十位else{wx3=1; P0=0xff; delay1(2); wx3=0;}wx4=1; P0=table1[H2]; delay1(2); wx4=0; //時個位 wx5=1; P0=0xC7; delay1(2); wx5=0; //Lwx6=1; P0=0xBF; delay1(2); wx6=0; //- wx7=1; P0=table[L1]; delay1(2); wx7=0; //分十位 wx8=1; P0=table[L2]; delay1(2); wx8=0; //分個位} if( (K1num==3)&&(K4num==2) ){TR1=1; wx1=1; P0=0x89; delay1(2); wx1=0; //H wx2=1; P0=0xBF; delay1(2); wx2=0; //-wx3=1; P0=table1[H1]; delay1(2); wx3=0; //時十位if(count2<60) {wx4=1; P0=table1[H2]; delay1(2); wx4=0;} //時個位else {wx4=1; P0=0xff; delay1(2); wx4=0;} wx5=1; P0=0xC7; delay1(2); wx5=0; //Lwx6=1; P0=0xBF; delay1(2); wx6=0; //- wx7=1; P0=table[L1]; delay1(2); wx7=0; //分十位 wx8=1; P0=table[L2]; delay1(2); wx8=0; //分個位} if( (K1num==3)&&(K4num==3) ){TR1=1; wx1=1; P0=0x89; delay1(2); wx1=0; //H wx2=1; P0=0xBF; delay1(2); wx2=0; //- wx3=1; P0=table1[H1]; delay1(2); wx3=0; //時十位wx4=1; P0=table1[H2]; delay1(2); wx4=0; //時個位 wx5=1; P0=0xC7; delay1(2); wx5=0; //Lwx6=1; P0=0xBF; delay1(2); wx6=0; //- if(count2<60){wx7=1; P0=table[L1]; delay1(2); wx7=0;} //分十位 else {wx7=1; P0=0xff; delay1(2); wx7=0;} wx8=1; P0=table[L2]; delay1(2); wx8=0; //分個位} if( (K1num==3)&&(K4num==4) ){TR1=1; wx1=1; P0=0x89; delay1(2); wx1=0; //H wx2=1; P0=0xBF; delay1(2); wx2=0; //- wx3=1; P0=table1[H1]; delay1(2); wx3=0; //時十位wx4=1; P0=table1[H2]; delay1(2); wx4=0; //時個位 wx5=1; P0=0xC7; delay1(2); wx5=0; //Lwx6=1; P0=0xBF; delay1(2); wx6=0; //- wx7=1; P0=table[L1]; delay1(2); wx7=0; //分十位if(count2<60) {wx8=1; P0=table[L2]; delay1(2); wx8=0;} //分個位else{wx8=1; P0=0xff; delay1(2); wx8=0;}}//喇叭開啟關(guān)閉顯示if( (K1num==4)&&(K5num==0) ){TR1=0; wx1=1; P0=0x92; delay1(2); wx1=0; //S wx2=1; P0=0x8C; delay1(2); wx2=0; //Pwx3=1; P0=0x81; delay1(2); wx3=0; //Awx4=1; P0=0xF0; delay1(2); wx4=0; //C wx5=1; P0=0xBF; delay1(2); wx5=0; //-wx6=1; P0=0xF7; delay1(2); wx6=0; //_ wx7=1; P0=0xF7; delay1(2); wx7=0; //_ wx8=1; P0=0xBF; delay1(2); wx8=0; //-}if( (K1num==4)&&(K5num==1) ){TR1=1; wx1=1; P0=0x92; delay1(2); wx1=0; //S wx2=1; P0=0x8C; delay1(2); wx2=0; //Pwx3=1; P0=0x81; delay1(2); wx3=0; //Awx4=1; P0=0xF0; delay1(2); wx4=0; //C wx5=1; P0=0xBF; delay1(2); wx5=0; //-wx6=1; P0=0xC0; delay1(2); wx6=0; //o wx7=1; P0=0x8E; delay1(2); wx7=0; //F wx8=1; P0=0x8E; delay1(2); wx8=0; //F}if( (K1num==4)&&(K5num==2) ){TR1=1; wx1=1; P0=0x92; delay1(2); wx1=0; //S wx2=1; P0=0x8C; delay1(2); wx2=0; //Pwx3=1; P0=0x81; delay1(2); wx3=0; //Awx4=1; P0=0xF0; delay1(2); wx4=0; //C wx5=1; P0=0xBF; delay1(2); wx5=0; //-wx6=1; P0=0xC0; delay1(2); wx6=0; //o wx7=1; P0=0xC8; delay1(2); wx7=0; //n wx8=1; P0=0xBF; delay1(2); wx8=0; //-} } //////////////////////////////////////////////////////////////////////////////////// ///////////////////按鍵功能設(shè)置///////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// void keycan(){/**********模式選擇***********/if( K1==0 ) { K1num++; delay(5);if( K1==0 ) { while(!K1); bi(350);if(K1num==5) { K1num=0;bi(650);TR0=1;TR1=0;} } }if(K1num!=0) {if( K2==0 ) { K2num++; K3num++; K4num++; K5num++; delay(5);if( K2==0 ) { while(!K2);bi(100); TR1=1;{if(K2num==5) { K2num=0;bi(400);TR1=0;}if(K3num==5) { K3num=0;bi(400);TR1=0;} if(K4num==5) { K4num=0;bi(400);TR1=0;} if(K5num==3) { K5num=0;bi(400);TR1=0;} }}} }if(K1num!=0) //加{if( K3==0 ) { delay(5);if( K3==0 ) { while(!K3); bi(100);if((K1num==1)&&(K2num==1)) { qian++; if(qian==3 ) qian=0; } if((K1num==1)&&(K2num==2)) { bai++; if( bai==10) bai=0; }if((K1num==1)&&(K2num==3)) { shi++; if( shi==6 ) shi=0; }if((K1num==1)&&(K2num==4)) { ge++; if( ge==10) ge=0; } if((K1num==2)&&(K3num==1)) { n1++; if( n1==3 ) n1=0; }if((K1num==2)&&(K3num==2)) { n2++; if( n2==10) n2=0; }if((K1num==2)&&(K3num==3)) { z1++; if( z1==6 ) z1=0; }if((K1num==2)&&(K3num==4)) { z2++; if( z2==19) z2=0; }if((K1num==3)&&(K4num==1)) { H1++; if( H1==10) H1=0; }if((K1num==3)&&(K4num==2)) { H2++; if( H2==10) H2=0; }if((K1num==3)&&(K4num==3)) { L1++; if( L1==10) L1=0; }if((K1num==3)&&(K4num==4)) { L2++; if( L2==10) L2=0; }if((K1num==4)&&(K5num==1)) { BEEP=0; } } }if( K4==0 ) { delay(5);if( K4==0 ) { while(!K4); bi(100);if((K1num==1)&&(K2num==1)) { qian--; if(qian==-1) qian=2; } if((K1num==1)&&(K2num==2)) { bai--; if( bai==-1) bai=9; }if((K1num==1)&&(K2num==3)) { shi--; if( shi==-1) shi=5; }if((K1num==1)&&(K2num==4)) { ge--; if( ge==-1) ge=9; }if((K1num==2)&&(K3num==1)) { n1--; if( n1==-1) n1=2; }if((K1num==2)&&(K3num==2)) { n2--; if( n2==-1) n2=9; }if((K1num==2)&&(K3num==3)) { z1--; if( z1==-1) z1=5; }if((K1num==2)&&(K3num==4)) { z2--; if( z2==-1) z2=9; }if((K1num==3)&&(K4num==1)) { H1--; if( H1==-1) H1=9; }if((K1num==3)&&(K4num==2)) { H2--; if( H2==-1) H2=9; }if((K1num==3)&&(K4num==3)) { L1--; if( L1==-1) L1=9; }if((K1num==3)&&(K4num==4)) { L2--; if( L2==-1) L2=9; }if((K1num==4)&&(K5num==2)) { bi(); } }} }}///////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////***********主函數(shù)********************/////////////////////////////////////////////////////////////void main(){ BEEP=0;init1();init2();qian=0;bai=6;shi=3;ge=0;miao2=0;miao1=0,H1=H2=L1=L2=2,n1=n2=z1=z2=1;while(1){ ReadTemperature();keycan();MODE();}} 上一頁 1 2 3 下一頁
評論