中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 秒表計時功能(模仿)單片機程序

        秒表計時功能(模仿)單片機程序

        作者: 時間:2012-10-11 來源:網絡 收藏

        下面這個仿真效果圖,大家可按上面的電路來制作

        點擊瀏覽下一頁

        /**//模仿,獨立按鍵可控制計時數字的“暫停/走動”。(程序沒有考慮計時)/*P2.2~P2.4與138譯碼器輸入口連接/*P1.0連接獨立按鍵/*P0口輸出數據***/#includeAT89X51.H>code unsigned char tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40}; //共陰數碼管 0-9  '-' '熄滅‘表unsigned int count,a,b,sec,min,hour; bit c_flag; // 暫停/計時 標志          /*****T1初始化*****/void timer_1(void){TH1=0x0ec;TL1=0x078;TR1=1;}/*****數據計數******/void time_count(viod){if(hour==60){sec=0,min=0,hour=0;}else if(sec!=59) sec++;else if(min!=59) {sec=0,min++;}else {min=0,hour++;}}/******數字調整*******/void get_count(unsigned int x){a=x/10;b=x%10;}/*******按鍵檢測********/void key_tach(void){int i,j;j=P10x01;if(j==0){for(i=0;i=200;i++);j=P10x01;if(j==0) {if(c_flag==1) c_flag=0;else c_flag=1;}}}/*******顯示程序********/void display(viod){   int flag;P0=0x00;flag=count%8;switch(flag){case 0:P2=flag*4;get_count(hour);P0=tab[a];break;case 1:P2=flag*4;P0=tab[b];break;case 2:P2=flag*4;P0=tab[10];break;case 3:P2=flag*4;get_count(min);P0=tab[a];break;case 4:P2=flag*4;P0=tab[b];break;case 5:P2=flag*4;P0=tab[10];break;case 6:P2=flag*4;get_count(sec);P0=tab[a];break;case 7:P2=flag*4;P0=tab[b];break;default:return;}}/*******中斷服務程序********/void int1() interrupt 3{key_tach();if(c_flag==0){if(count==7) {count=0;time_count();}else count++;}else{if(count==7) {count=0;}else count++;} display();timer_1();}/******主程序*****/void main(){c_flag=0;count=0;sec=0;min=0;hour=0;TMOD=0x10;EA=1;ET1=1;timer_1();while(1);}


        評論


        技術專區(qū)

        關閉