看看这样行不?基本没做大的改动,只是增加延时部分。
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula = P2^6;
sbit wela = P2^7;
unsigned char code tabledu[] = {0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x00};
unsigned char code tablewe[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void DelayMS(uint x)
{
uchar t;
while(x--) for(t=0;t<50;t++);
}
void main()
{
while(1)
{
uchar m=0,n;
for(n = 100; n >0; n--);
{
for(m=0;m<8;m++)
{
dula=1;
P0 = tabledu[m];
dula=0;
wela=1;
P0 = tablewe[m];
wela=0;
DelayMS(300);
}
}
}
} |