找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5208|回復(fù): 3
收起左側(cè)

求解 通過AT89C51的定時器實現(xiàn).60S倒計時,顯示采用兩位數(shù)碼管動態(tài)顯示

[復(fù)制鏈接]
ID:57267 發(fā)表于 2013-11-25 22:34 | 顯示全部樓層 |閱讀模式
通過AT89C51的定時器實現(xiàn).60S倒計時,顯示采用兩位數(shù)碼管動態(tài)顯示。用C語言寫

回復(fù)

使用道具 舉報

ID:56580 發(fā)表于 2013-11-26 01:49 | 顯示全部樓層
#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned int

uchar code table[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code LED_W[8] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void delay(uint i)
{
        uint x,j;
        for(j=0;j<i;j++)
        for(x=0;x<=148;x++);       
}

void display(uint temp)
{
                P0=0;
                P2=0xfb;
                P0=table[temp/100];
                delay(2);
                P0=0;
                P2=0xfd;
                P0=table[temp%100/10];
                P0=P0 | 0x80;
                delay(2);
                P0=0;
                P2=0xfe;
                P0=table[temp%10];
                delay(2);

}

void main()
{
        uint i=100,j;

        while(1)
        {          if(i!=0)
                        {
                for(j=0;j<10;j++)
                {
               
          display(i);
          }
                       
                               
                i--;
            }
                       
                        else
                   {  
                   while(1)
                   {  uint i;
                      for(i=0;i<10;i++)
                              {P2=0xfe;
                           P0=0x3f;
                           delay(2);
                           P2=0xfd;
                           P0=0x3f;
                           delay(2);
                       P2=0xfb;
                           P0=0x3f;
                           delay(2);}
                          
                           P2=0xff;
                           delay(200);
                  
                  
                  
                   }
                               

                        }
               
        }
}



你自己參考一下吧

評分

參與人數(shù) 1黑幣 +4 收起 理由
51pp + 4 很給力!

查看全部評分

回復(fù)

使用道具 舉報

ID:57234 發(fā)表于 2013-11-26 03:21 | 顯示全部樓層
還是版主牛逼這么快就搞定了
回復(fù)

使用道具 舉報

ID:153199 發(fā)表于 2016-12-17 11:49 | 顯示全部樓層
厲害,值得參考
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表