研究生
最后登录1970-1-1
在线时间 小时
注册时间2021-1-2
|
发表于 2021-1-25 10:05:54
|
显示全部楼层
if (direction == RIGHT) //右转
{
switch (cnt)
{
case 0: //节拍0
StepMotor_Control(MOTOR_A,HIGH);
StepMotor_Control(MOTOR_AA,LOW);
StepMotor_Control(MOTOR_B,LOW);
StepMotor_Control(MOTOR_BB,HIGH);
break;
case 1: //节拍1
StepMotor_Control(MOTOR_A,HIGH);
StepMotor_Control(MOTOR_AA,LOW);
StepMotor_Control(MOTOR_B,HIGH);
StepMotor_Control(MOTOR_BB,LOW);
break;
case 2: //节拍2
StepMotor_Control(MOTOR_A,LOW);
StepMotor_Control(MOTOR_AA,HIGH);
StepMotor_Control(MOTOR_B,HIGH);
StepMotor_Control(MOTOR_BB,LOW);
break;
case 3: //节拍3
StepMotor_Control(MOTOR_A,LOW);
StepMotor_Control(MOTOR_AA,HIGH);
StepMotor_Control(MOTOR_B,LOW);
StepMotor_Control(MOTOR_BB,HIGH);
break;
}
}
else if (direction == LEFT) //左转
{
switch (cnt)
{
case 0: //节拍0
StepMotor_Control(MOTOR_A,HIGH);
StepMotor_Control(MOTOR_AA,LOW);
StepMotor_Control(MOTOR_B,LOW);
StepMotor_Control(MOTOR_BB,HIGH);
break;
case 1: //节拍1
StepMotor_Control(MOTOR_A,LOW);
StepMotor_Control(MOTOR_AA,HIGH);
StepMotor_Control(MOTOR_B,LOW);
StepMotor_Control(MOTOR_BB,HIGH);
break;
case 2: //节拍2
StepMotor_Control(MOTOR_A,LOW);
StepMotor_Control(MOTOR_AA,HIGH);
StepMotor_Control(MOTOR_B,HIGH);
StepMotor_Control(MOTOR_BB,LOW);
break;
case 3: //节拍3
StepMotor_Control(MOTOR_A,HIGH);
StepMotor_Control(MOTOR_AA,LOW);
StepMotor_Control(MOTOR_B,HIGH);
StepMotor_Control(MOTOR_BB,LOW);
break;
}
} |
|