欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 單片機秒表 [打印本頁]

作者: zqfzqf    時間: 2018-12-4 19:00
標題: 單片機秒表
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char code table []={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char count=0,b;
sbit key=P3^7;     //定義按鍵
uchar ds_time = 0;
uchar i;
uchar t=0;
void delay(uint i)     //延時
{
  char j;
  for(i; i > 0; i--)
  for(j = 200; j > 0; j--);
}
void main()      //主函數
{
  TMOD=0x01;      //方式1
  TH0=0x3c;        //
  TL0=0xb0;
  ET0=1;          //中斷開
  //TR0=1;
  EA=1;          //總中斷開
  key=1;
  while(1){
            if(key==0)      //按鍵按下
             {
                          delay(10);
              TR0=~TR0;
                          while(!key)     //消抖
              {
                           b++;      //
               delay(1000);
               if(b>100)
               {
                            b=0;
                count=0;
                                              TR0=0;
          }
          }
     
     }
     if(ds_time==1){
      ds_time=0;
      P0=table[count/10];         //十位
      P2=table[count%10];            //個位
      count++;             //數碼管加1
              }
                          }         
}
timer0() interrupt 1{      //中斷
              t++;
              if(t==20){
                                t=0;
                                                        ds_time=1;            
                          }
        TH0=0x3c;
                          TL0=0xb0;
}

截圖.png (21.05 KB, 下載次數: 27)

截圖.png

單片機秒表.docx

31.95 KB, 下載次數: 3, 下載積分: 黑幣 -5

秒表






歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1