標(biāo)題: 實(shí)用簡(jiǎn)易秒表,仿真文件損壞了只有截圖 [打印本頁(yè)]

作者: l1h2h3    時(shí)間: 2020-5-5 22:42
標(biāo)題: 實(shí)用簡(jiǎn)易秒表,仿真文件損壞了只有截圖
#include<reg51.h>
unsigned int count=0;
unsigned char miao=0;
sbit S1=P1^0;
sbit S2=P1^1;
sbit S3=P1^2;
void timer_1()interrupt 3
{
TH1=256-250/1;
TL1=256-250/1;
count++;
if(count==2000)
{
  count=0;
  miao++;
  if(miao==100) miao=0;
}
}
void disp(unsigned char i)
{
unsigned char j;
unsigned char led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
P3=0xff;
P2=led[i/10];
P3=0xfe;
for(j=0;j<100;j++);
P3=0xff;
P2=led[i%10];
P3=0xfd;
for(j=0;j<100;j++);
}
void main()
{
  TMOD=0X20;
  TH1=256-250/1;
  TL1=256-250/1;
  ET1=1;
  EA=1;
  TR1=0;
  while(1)
{
    if(S1==0)
   {
    while(!S1);
     if(S1==1)
     {TR1=1;
     while(1)
     {
         disp(miao);
         if(S2==0||S3==0)break;
         }
         }
   }
    if(S2==0)
   {
    while(!S2);
    if(S2==1)
    {TR1=0;
        while(1)
        {
        disp(miao);
        if(S1==0||S3==0)break;
        }          
        }
   }
   if(S3==0&&miao!=0)
   {       
    while(S3==0);
           if(S3==1)
    {TR1=0,miao=0;
    while(1)
    {disp(miao);
     if(S1==0||S2==0)
     break;
    }
    }
   }
}
}  

b60e6832fa5e124154225043caad741.png (31.34 KB, 下載次數(shù): 48)

仿真

仿真





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