|
发表于 2013-11-7 01:30:33
|
显示全部楼层
修改Moto.c文件:- #include "motor.h"
- #include "uart.h"
- #include "timer.h"
- bit Cruising_Flag;
- uchar Robots_Run_Status;
- bit Pre_Cruising_Flag;
- /**电机初始化**/
- void Motor_Init(void)
- {
- MOTOR_A_EN=1;
- MOTOR_B_EN=1;
- MOTOR_GO_STOP;
- }
- void Cruising_Mod(void)
- {
-
- Cruising_Flag=1;//固定开启
- if(1 == Cruising_Flag)
- {
- switch(Robots_Run_Status)
- {
- case 0x01:MOTOR_GO_RIGHT; break; //状态偏左
- case 0x02:MOTOR_GO_LEFT; break; //状态偏右
- case 0x03:MOTOR_GO_FORWARD; break; //直行状态
- case 0x04:MOTOR_GO_STOP; break; //停止状态
- }
- if((Input_Detect0 == 1)&& (Input_Detect1 == 0))
- {
- Robots_Run_Status = 0x01;
- }
- else if((Input_Detect0 == 0)&& (Input_Detect1 == 1))
- {
- Robots_Run_Status = 0x02;
- }
- else if((Input_Detect0 == 0)&& (Input_Detect1 == 0))
- {
- Robots_Run_Status = 0x04;
-
- }
- else
- {
- Robots_Run_Status = 0x03;
-
- }
- }
- }
复制代码 |
|