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

標題: 為什么6位數碼管最后一位用不了? [打印本頁]

作者: 喻小見    時間: 2014-7-31 15:04
標題: 為什么6位數碼管最后一位用不了?
#include<reg51.h>
unsigned char code LedChar[] = {                 //數碼管顯示數
        0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
    0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E               
};
unsigned char LedBuff[7] = {                                 //數碼管顯示緩沖區
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xFF
};
unsigned char code Table[] = {
        0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF
};
void DisPlay(unsigned long num);
void delay1ms(unsigned char n);
void LedScan();
void main()
{

        DisPlay(53467);                //數碼管顯示0   高位為0不顯示
        LedScan();
}
void DisPlay(unsigned long num)
{
    signed char i;
    unsigned char buf[6];

    for (i=0; i<6; i++)   //把長整型數轉換為6位十進制的數組
    {
        buf = num % 10;
        num = num / 10;
    }
    for (i=5; i>=1; i--)  //從最高位起,遇到0轉換為空格,遇到非0則退出循環
    {
        if (buf == 0)
            LedBuff = 0xFF;
        else
            break;
    }
    for ( ; i>=0; i--)    //剩余低位都如實轉換為數碼管顯示字符
    {
        LedBuff = LedChar[buf];
    }
}
void LedScan()
{
        unsigned char i;
        P0 = 0xFF;
        for (i=0; i<6; i++)
        {
                P2 = Table;
                P0 = LedBuff;
                delay1ms(1);        
        }

}
void delay1ms(unsigned char n)
{
        static unsigned char i;
        while(n--)
        for(i=0;i<125;i++);




資料:
http://bbs.dzsc.com/showtopic-371170.html






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