#include<reg52.h>
#define led P2
#define IN1 P2
unsigned char aa=0;
unsigned int i,z=5,g;
void main()
{
TMOD|=0x01;
TH0=0xFF;
TL0=0xF6;
ET0=1;
TR0=1;
EA=1;
while(1)
{
if(i<z) {IN1=1;P2=0xff;}
else {IN1=0;}
if(i>=900){i=0;}
if(z==5) {g=0;}
if(z==800){g=1;}
if(g==0) {z++;}
if(g==1) {z--;}
}
}
void timer0() interrupt 1
{
TH0=0xFF;
TL0=0xF6; //1111 1111 1010 0100
i++;
}
|