#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,aa,num;
sbit duan=P2^2;
sbit wei=P2^3;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(uint);
void InitTimer();
void main()
{
num=0;
InitTimer();
temp=0xfe;
P1=temp;
duan=1;
P0=table[0];
duan=0;
wei=1;
P0=0x00;
wei=0;
while(1)
{
delay(1000);
temp=_crol_(temp,1);
P1=temp;
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void InitTimer()
{
TMOD = 0x01;
TH0 = (65536-50000)/256;
TL0 = (65536-50000)%256;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void Timer() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==40)
{
aa=0;
num++;
if(num==16)
num=0;
duan=1;
P0=table[num];
duan=0;
}
} |