论坛元老
- 积分
- 4638
- 金钱
- 4638
- 注册时间
- 2017-7-6
- 在线时间
- 705 小时
|
5金钱
我自己写了个程序,虽然实现了一模一样的波形,但是占存储空间很大,还有十几个这样的波形呢,我只做了3个,空间就用了百分之20多。
if(r_PWM_t < 26) //1个
{
Motor = 0;
}
else if(r_PWM_t <= 73)
{
r_PWM_3t++;
if(r_PWM_3t == 5)
{
r_PWM_3t = 0;
b_t = 1;
}
if(b_t)
{
b_t = 0;
Motor = ~Motor;
}
}
else if(r_PWM_t < 99) //2个
{
Motor = 0;
}
else if(r_PWM_t <= 146)
{
r_PWM_3t++;
if(r_PWM_3t == 5)
{
r_PWM_3t = 0;
b_t = 1;
}
if(b_t)
{
b_t = 0;
Motor = ~Motor;
}
}
else if(r_PWM_t < 172) //3个
{
Motor = 0;
}
else if(r_PWM_t <= 219)
{
r_PWM_3t++;
if(r_PWM_3t == 5)
{
r_PWM_3t = 0;
b_t = 1;
}
if(b_t)
{
b_t = 0;
Motor = ~Motor;
}
}
else if(r_PWM_t < 245) //4个
{
Motor = 0;
}
else if(r_PWM_t <= 292)
{
r_PWM_3t++;
if(r_PWM_3t == 5)
{
r_PWM_3t = 0;
b_t = 1;
}
if(b_t)
{
b_t = 0;
Motor = ~Motor;
}
}
else if(r_PWM_t <= 302)
{Motor = 0;}
else if(r_PWM_t <= 307)
{b_1t = 1;}
else if(r_PWM_t <= 312)
{
Motor = 1;
b_1t = 0;
}
else if(r_PWM_t <= 317)
{b_1t = 1;}
else if(r_PWM_t <= 322)
{
Motor = 1;
b_1t = 0;
}
else if(r_PWM_t <= 327)
{b_1t = 1;}
else if(r_PWM_t <= 332)
{
Motor = 1;
b_1t = 0;
}
else if(r_PWM_t <= 337)
{b_1t = 1;}
else if(r_PWM_t <= 342)
{
Motor = 1;
b_1t = 0;
}
else if(r_PWM_t <= 346)
{b_1t = 1;}
if(r_PWM_t > 346)
{
r_PWM_t = 0;
b_1t = 0;
}
}
if(b_1t)
{
if(r_PWM_4t > 1)
{Motor = 0;}
else {Motor = 1;}
if(r_PWM_4t > 12)
{r_PWM_4t = 0;}
}
|
-
总的
-
后面一下段
|