兼职项目 智能自行车
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
719 B

3 years ago
#include "pwm.h"
unsigned char pwm_val_right =0;
unsigned char push_val_right=0;
3 years ago
unsigned char pwm_value=0;
3 years ago
extern uint model;
bit Right_moto_stop = 0;
void delay(unsigned int k)
3 years ago
{
unsigned int x,y;
3 years ago
for(x=0;x<k;x++)
for(y=0;y<2000;y++);
}
void run(void)
3 years ago
{
if(model == 0) pwm_value = 0;
else if(model == 1) pwm_value = 2;
else if(model == 2) pwm_value = 5;
else pwm_value = 10;
push_val_right=pwm_value;
Right_moto_back;
3 years ago
}
void pwm_out_right_moto(void)
3 years ago
{
pwm_val_right++;
if(~Right_moto_stop){
if(pwm_val_right <= push_val_right)
{
Right_moto_pwm=1;
}
else
{
Right_moto_pwm=0;
}
if(pwm_val_right>=20) pwm_val_right=0;
}
else{
Right_moto_pwm=0;
}
3 years ago
}