#include <stdio.h>
int main()
{
int PWM_numb = 0;
int PWM_but = 0;
int num = 0;//输出次数超过10000跳出循环
int i=0;//输出换行用
while(1)
{
if(PWM_numb == 0)
{
PWM_but++;
if(PWM_but>1000)
PWM_numb = 1;
}
else if(PWM_numb == 1)
{
PWM_but--;
if(PWM_but<1)
PWM_numb = 0;
}
if(i++< 29)
printf("%d ",PWM_but);
else
{
i=0;
printf("%d\n",PWM_but);
}
if(num++ >10000)
break;
}
return 0;
}
这是测试结果 |