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

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

按鍵計數器

作者:佚名   來源:本站原創   點擊數:  更新時間:2010年10月04日   【字體:
______________________________________

功能:通過按鍵,控制2位數碼管100內計數

時間:2010—7—18

______________________________________


#include<reg52.h>

 

code unsigned char tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; 

unsigned char Dis_Shiwei;
unsigned char Dis_Gewei;

void delay(unsigned int cnt)
{
        while(--cnt);
}

main()
{

        EA=1;
        EX0=1;    //外部中斷0開
        IT0=1;    //邊沿觸發

        while(1)
        {
                P0=Dis_Shiwei;
                P2=0;
                delay(300);
                P0=Dis_Gewei;
                P2=1;
                delay(300);
        }

}

void INT0_ISR(void) interrupt 0 using 1    //外部中斷函數
{
        static unsigned char second;

        second++;
        if(second==100)
                second=0;
        Dis_Shiwei=tab[second/10];
        Dis_Gewei=tab[second%10];     
}
關閉窗口

相關文章