#include<reg51.h>
#define uchar unsigned char
bit ldelay=0;
uchar t=0;
void main(){
uchar code ledp[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar ledi;
TMOD=0x01;
TH0=0x3c;
TL0=0xb0;
TR0=1;
ET0=1;
EA=1;
while(1){
if(ldelay){
ldelay=0;
P2=ledp[ledi];
ledi++;
if(ledi==8)ledi=0;
}}}
timer0() interrupt 1{
t++;
if(t==20) {t=0; ldelay=1;}
TH0=0x3c; TL0=0xb0;
}
|