红外避障小车c语言程序(精品)
HYPERLINK "/share/detail \l "content" ?? HYPERLINK "/share/detail \l "content"
智能小车红外避障c语言程序
#include
bit RandomFactor = 0 ;bit RandomFactorBuf = 0 ;#include
#define FLeftMotor P0_2 = 1 ; P0_3 = 0 #define BLeftMotor P0_2 = 0 ; P0_3 = 1
#define FRightMotor P0_5 = 1 ; P0_4 = 0 #define BRightMotor P0_5 = 0 ; P0_4 = 1
#define LeftStop??? P0_2 = 0 ; P0_3 = 0 #define RightStop?? P0_4 = 0 ; P0_5 = 0
#define CarStop P0_2 = 0 ; P0_3 = 0 ; P0_4 = 0 ; P0_5 = 0
#define RightSenser P0_0 #define LeftSenser P0_1
//********************************************************
// 左转
//********************************************************
void TurnLeft_1(){LeftStop ;FRightMotor ;
}
//********************************************************
// 快速左转
//********************************************************void TurnLeft_Fast(){BLeftMotor ;FRightMotor ;}
//********************************************************
// 右转
//********************************************************void TurnRight_1(){RightStop ;FLeftMotor ;}
//********************************************************
// 快速右转
//********************************************************void TurnRight_Fast(){BRightMotor ;FLeftMotor ;}
//********************************************************
// 用倒退的方式进行车头右转
//********************************************************void BTurnRight_1(){LeftStop ;BRightMotor ; }
//********************************************************
// 用倒退的方式进行车头左转
//********************************************************void BTurnLeft_1(){ RightStop ;BLeftMotor ; }
//********************************************************
// 前进
//********************************************************
void FCar(){FLeftMotor ;FRightMotor ;}
//********************************************************
// 后退
//********************************************************void BCar(){BLeftMotor ;BRightMotor ;}
//*****************************************
本文提供了一款红外避障小车的C语言程序源码,详细展示了如何通过控制电机来实现小车的基本转向操作,包括左转、右转、前进及后退等,并利用红外传感器进行障碍物检测。
2231

被折叠的 条评论
为什么被折叠?



