標(biāo)題: 51單片機(jī)簡(jiǎn)易電子時(shí)鐘,寫的代碼運(yùn)行不出來 [打印本頁]

作者: aaaa199    時(shí)間: 2023-4-16 00:01
標(biāo)題: 51單片機(jī)簡(jiǎn)易電子時(shí)鐘,寫的代碼運(yùn)行不出來


#include <reg51.h>
unsigned char code LED[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char s=55,m=59,h=23;
unsigned char i1,j1,i2,j2,i3,j3,t;
void delay(unsigned int time)
{
    unsigned int j=0;
        for(;time>0;time--)
          for(j=0;j<125;j++);
}
void main()
{
  TMOD=0x01;
        TH0=0x3c;
        TL0=0xb0;
        TR0=1;
        ET0=1;
        EA=1;
        while(1);
        {
                        if (s==60)
                          { s=0;m++;}
                          i1=s/10;
                          j1=s%10;
                        if (m==60)
                          { m=0;h++;}
                          i2=m/10;
                          j2=m%10;
                        if (h==24)
                           h=0;
                          i3=h/10;
                          j3=h%10;
                  P2=0xfe;P0=LED[j1];delay(1);
                        P2=0xfd;P0=LED[i1];delay(1);
                        P2=0xfb;P0=LED[j2];delay(1);
                        P2=0xf7;P0=LED[i2];delay(1);
                        P2=0xef;P0=LED[j3];delay(1);
                        P2=0xdf;P0=LED[i3];delay(1);   
        }
}
void timer0() interrupt 1 {
   t++;
   if (t==20)
   {   t=0;
             s++;
   }
   TH0=0x3c;
   TL0=0xb0;
}


作者: wulin    時(shí)間: 2023-4-16 06:46
while(1); 多了個(gè)分號(hào)
作者: csmyldl    時(shí)間: 2023-4-16 08:41
while(1);此句后的轟號(hào)應(yīng)去掉
作者: Muii    時(shí)間: 2023-4-17 00:51
while(1)即可 多了分號(hào)
作者: man1234567    時(shí)間: 2023-4-17 11:23
while(1); 編譯不會(huì)通過;
delay(1); 可能結(jié)果會(huì)有。
理論上以上和運(yùn)行不起來都沒關(guān)系。




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