关于两位数码管显示00-99的问题,只能记偶数,奇数无法显示

2019-07-16 01:19发布

#include <regx51.h>
unsigned char code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code table2[]={0x7f,0xbf};
unsigned char  table3[2];
int count=0;
unsigned char i=0;
/********************Delay function************************/
void delay(unsigned int t)
{
        unsigned char i=250;
        while(t--)while(i--);
}
/**********************Display function********************/
void smg( int count)                        //数码管显示2位数字
{
table3[0]=count%10;                       
table3[1]=count/10;       

P3= table2[i];                       
P0=table1[table3[i]];         //送出段选数据
delay(20);        
i++;                                             //扫描指针加计数
if(i==2)
i=0 ;       
       
        }
/**********************Main function*************************/
void main()
{
            count=0;
                P0=0x00;
          while(1)
                 {
                          smg(count);
                          count++;
                          if(count==100)   //循环计数
                          count=0;       
                }
        }
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
2条回答
闲中偷忙
2019-07-16 05:37
void smg( int count)                        //数码管显示2位数字
{
table3[0]=count%10;                        
table3[1]=count/10;        

P3= table2[i];                        
P0=table1[table3[i]];         //送出段选数据
delay(20);
i++;        
P3= table2[i];                        
P0=table1[table3[i]];         //送出段选数据
delay(20);
i=0 ;        
    }这样改试试看

一周热门 更多>