找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1219|回復: 0
打印 上一主題 下一主題
收起左側

單片機雙數(shù)碼管1分鐘計時新手入門

[復制鏈接]
跳轉到指定樓層
樓主
ID:773907 發(fā)表于 2020-6-9 14:00 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
#include<reg51.h>
unsigned char code c[]={0xc0,0xf9,0xA4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char code cd[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xA4,0xf9,0xc0};
unsigned char second;
unsigned  char tcount;

void  main()
{
    TMOD=0x01;
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
    ET0=1;
        EA=1;
        TR0=1;
        tcount=0;
        second=0;
        P0=c[second/10];//0
        P2=c[second%10];//0
        while(1)//50ms
        {
           if(TF0==1)           //開啟查詢
           {
                    tcount++;
             if(tcount==20)//1s
        {
                tcount=0;
                second++;//1
                   if(second==60)
                    {
                        second=0;
                        }
                P0=c[second/10];
            P2=c[second%10];
            }
           TF0=0;   //手動置0
           TH0=(65336-50000)/256;
           TL0=(65336-50000)%256;           
           }        
        }
}
void t0(void) interrupt 1 using 0
{

}


雙數(shù)碼管.zip

76.58 KB, 下載次數(shù): 3, 下載積分: 黑幣 -5

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

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

本版積分規(guī)則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表