#include "reg52.h"
unsigned char count;
sbit pwm =P3^0 ;
unsigned char jd;
void delay(unsigned char i)
{
unsigned char j,k;
for(j=i;j>0;j--)
for(k=125;k>0;k--);
}
void Time0_Init()
{
TMOD = 0x01;
IE = 0x82;
TH0 = 0xfe;
TL0 = 0x33;
TR0=1;
}
void Time0_Int() interrupt 1
{
TH0 = 0xfe;
TL0 = 0x33;
if(count<jd)
pwm=1;
else
pwm=0;
count=(count+1);
count=count%40;
}
void main()
{
jd=1;
count=0;
Time0_Init();
while(1)
{
for(jd=1;jd<6;jd++)
count=0;
for(jd=5;jd>0;jd--)
count=0;
}
}
|