#include<reg51.h>
#define uchar unsigned char
uchar pwm,cnt;
sbit pluse=P1^0;
void t0isr() interrupt 1
{
cnt++;
if(cnt<pwm)pluse=1;
else pluse=0;
if(cnt>100)cnt=0;
}
main()
{
TMOD=0x02;
TH0=156;
TL0=156;
TR0=1;
ET0=1;
EA=1;
pwm=20;
while(1);
}
温馨提示:答案为网友推荐,仅供参考