#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code tablewe[]={
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f
};
uchar code tabledu[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};
uchar aa,numwe,numdu;
void delay(uint z);
void main()
{
aa=0;
numwe=0;
numdu=0;
P3=0XFF;
P0=0XFF;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;//开总中断
ET0=1;//开定时器0中断
TR0=1;//启动定时器0
while(1)
{
if(aa==10)
{
aa=0;
P3=tablewe[numwe];
if(numwe!=7)
numwe++;
else numwe=0;
delay(100);
P0=tabledu[numdu];
if(numdu!=15)
numdu++;
else numdu=0;
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=98;y>0;y--);
}
|