#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
void delayms(uint);
uchar m,n;
uchar code duanma[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code weima[]={0xfe,0xfd,0xfb,0xf7,
0xef,0xdf,0xbf,0x7f};
void main()
{
while(1)
{
m=5;
for(n=2;n<8;n++)
{
dula=1;
P0=duanma[n];
dula=0;
P0=0xff;
wela=1;
P0=weima[m];
wela=0;
delayms(1);
m--;
if(m==6)
m=0;
}
}
}
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
|