|
#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;}
sbit RightSenser=P0^0;
sbit LeftSenser=P0^1;
//********************************************************
// 左轉(zhuǎn)
//********************************************************
void TurnLeft_1()
{
LeftStop ;
FRightMotor ;
}
//********************************************************
// 快速左轉(zhuǎn)
//********************************************************
void TurnLeft_Fast()
{
BLeftMotor ;
FRightMotor ;
}
//********************************************************
// 右轉(zhuǎn)
//********************************************************
void TurnRight_1()
{
RightStop ;
FLeftMotor ;
}
//********************************************************
// 快速右轉(zhuǎn)
//********************************************************
void TurnRight_Fast()
{
BRightMotor ;
FLeftMotor ;
}
//********************************************************
// 用倒退的方式進(jìn)行車頭右轉(zhuǎn)
//********************************************************
void BTurnRight_1()
{
LeftStop ;
BRightMotor ;
}
//********************************************************
// 用倒退的方式進(jìn)行車頭左轉(zhuǎn)
//********************************************************
void BTurnLeft_1()
{ RightStop ;
BLeftMotor ;
}
//********************************************************
// 前進(jìn)
//********************************************************
void FCar()
{
FLeftMotor ;
FRightMotor ;
}
//********************************************************
// 后退
//********************************************************
void BCar()
{
BLeftMotor ;
BRightMotor ;
}
//********************************************************
// 壁障程序
//********************************************************
void Obstacle_Avoid(void)
{
if(RightSenser && LeftSenser)
{
FCar() ;
}
if((!RightSenser) && LeftSenser)
{
BTurnLeft_1() ;
}
if(RightSenser && (!LeftSenser))
{
BTurnRight_1() ;
}
這個(gè)程序的編譯結(jié)果總是顯示
Build target 'Target 1'
assembling STARTUP.A51...
compiling bizhang.c...
BIZHANG.C(25): error C141: syntax error near '='
BIZHANG.C(25): error C141: syntax error near '='
BIZHANG.C(26): error C141: syntax error near '='
BIZHANG.C(26): error C141: syntax error near '='
BIZHANG.C(37): error C141: syntax error near '='
BIZHANG.C(37): error C141: syntax error near '='
BIZHANG.C(38): error C141: syntax error near '='
BIZHANG.C(38): error C141: syntax error near '='
BIZHANG.C(48): error C141: syntax error near '='
BIZHANG.C(48): error C141: syntax error near '='
BIZHANG.C(49): error C141: syntax error near '='
BIZHANG.C(49): error C141: syntax error near '='
BIZHANG.C(59): error C141: syntax error near '='
BIZHANG.C(59): error C141: syntax error near '='
BIZHANG.C(60): error C141: syntax error near '='
BIZHANG.C(60): error C141: syntax error near '='
BIZHANG.C(70): error C141: syntax error near '='
BIZHANG.C(70): error C141: syntax error near '='
BIZHANG.C(71): error C141: syntax error near '='
BIZHANG.C(71): error C141: syntax error near '='
BIZHANG.C(80): error C141: syntax error near '='
BIZHANG.C(80): error C141: syntax error near '='
BIZHANG.C(81): error C141: syntax error near '='
BIZHANG.C(81): error C141: syntax error near '='
BIZHANG.C(92): error C141: syntax error near '='
BIZHANG.C(92): error C141: syntax error near '='
BIZHANG.C(93): error C141: syntax error near '='
BIZHANG.C(93): error C141: syntax error near '='
BIZHANG.C(103): error C141: syntax error near '='
BIZHANG.C(103): error C141: syntax error near '='
BIZHANG.C(104): error C141: syntax error near '='
BIZHANG.C(104): error C141: syntax error near '='
Target not created
請各位幫忙修改一下…… |
|