📄 c_carcontrl.h
字号:
//==========================================左轮控制
//左前直走
void CC_Goahead_L()
{
output_low(ELeft_M0);
output_high(ELeft_M1);
}
//左后直走
void CC_GoBack_L()
{
output_low(ELeft_M1);
output_high(ELeft_M0);
}
//左停止
void CC_Stop_L()
{
output_low(ELeft_M0);
output_low(ELeft_M1);
}
//==========================================右轮控制
//右前直走
void CC_Goahead_R()
{
output_low(ERight_M0);
output_high(ERight_M1);
}
//右后直走
void CC_GoBack_R()
{
output_low(ERight_M1);
output_high(ERight_M0);
}
//右停止
void CC_Stop_R()
{
output_low(ERight_M1);
output_low(ERight_M0);
}
//===============================================两轮控制
//左转90
void CC_turnleft90()
{
CC_GoBack_L();
CC_Goahead_R();
}
//右转90
void CC_turnright90()
{
CC_GoBack_R();
CC_Goahead_L();
}
//停止
void CC_CarStop()
{
output_low(ELeft_M0);
output_low(ELeft_M1);
output_low(ERight_M1);
output_low(ERight_M0);
}
//倒转
void CC_carGoBack()
{
CC_GoBack_R();
CC_GoBack_L();
}
//贴左墙走
void Left_along()
{
if(LS==1)
{
PWM_SetDRC(1,2);
PWM_SetDuty(70,70);
}
else if(RS==1)
{
PWM_SetDRC(2,1);
PWM_SetDuty(70,70);
}
else
{
PWM_SetDuty(22,22);
PWM_SetDRC(1,1);
}
}
//贴左墙走带参数
void Left_along(unsigned char Lefttmp,unsigned char righttmp)
{
if(LS==1)
{
PWM_SetDRC(1,2);
PWM_SetDuty(70,70);
}
else if(RS==1)
{
PWM_SetDRC(2,1);
PWM_SetDuty(70,70);
}
else
{
PWM_SetDuty(Lefttmp,righttmp);
PWM_SetDRC(1,1);
}
}
//贴右墙走
void Right_along()
{
if(RS==1)
{
PWM_SetDRC(2,1);
PWM_SetDuty(90,90);
}
else
{
PWM_SetDuty(22,22);
PWM_SetDRC(1,1);
}
}
//电磁铁断开 0 关闭 1 开启
void Iron(int1 enable)
{
if (enable==1)
{
output_low(EEorn);
}
else
{
output_high(EEorn);
}
}
//喇叭 0 关闭 1 开启
void Beep(int1 enable)
{
if (enable==1)
{
output_high(EBeep);
}
else
{
output_low(EBeep);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -