8*8点阵显示数字出现鬼影现象,求大神帮忙改程序

2019-07-15 21:07发布

本人新手
P1是列,P2是行。求帮忙修改,谢谢!
程序如下:
#include<reg52.h>  
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code graph[11][8]={
{0x0,0x8,0x18,0x8,0x8,0x8,0x8,0x8},//1
{0x0,0x18,0x24,0x24,0x8,0x10,0x20,0x3C},//2
{0x0,0x18,0x24,0x4,0x8,0x24,0x24,0x18},//3
{0x0,0x8,0x8,0x18,0x28,0x3C,0x8,0x8},//4
{0x0,0x3C,0x20,0x38,0x4,0x4,0x24,0x18},//5
{0x0,0x18,0x24,0x20,0x38,0x24,0x24,0x18}//6
};
unsigned char DisplayData;
unsigned char count;
unsigned char cnta;
sbit P35=P3^5;//按键开关定义
void Delay()
{
    unsigned char a,b;
   for(a=5;a>0;a--)
     for(b=248;b>0;b--);
}
void main()
{  
TMOD=0x01;
TH0=(65536-3000)/256;   
TL0=(65536-3000)%256;      
TR0=0;  
ET0=1;
EA=1;
while(1)
{
DisplayData=TH0%10;
  if(P35==0)
  {
   
while(P35==0);
{
    TR0=1;
     P2=tab[cnta];
        P1=graph[DisplayData][cnta];
     Delay();
    }
    }
    }
}
void t0(void) interrupt 1 using 0
{
TH0=(65536-3000)/256;   
TL0=(65536-3000)%256;   
  P2=tab[cnta];
  P1=graph[DisplayData][cnta];
    cnta++;
  if(cnta==8)
  {
   cnta=0;
  }
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。