📄 main.c
字号:
#include<spce061a_chf.h>
#include"bit.h"
#include"qiao.h"
//extern up_flag;
//unsigned int state_flag=0;
extern sec;
///////////////////////////////////////////
//函数:int main(void)
//描述:寻迹,开车,平衡判断
//参数:无
//返回:无
/////////////////////////////////////////////
int main(void)
{
init_IO();
while(1)
{
sec=0;
while((P1_2==0)|(P1_4==0))//先检测水银开关
{
/*while((P1_1==0)&(P1_7==0))
{
control_up(A1,B1);//还要测试速度???????????????
}
while(P1_1==1)
{
control_left(0,0);
}
while(P1_7==1)
{
control_right(0,0);
}
control_stop();*/
control_up();
delay();
delay();
delay();
}
P1_15=1;
control_stop();
delay();
delay();
delay();
sec=0;
lab: while((P1_3==0)|(P1_5==0))//说明已经向下倾斜了
{
control_goback();
delay();
//delay();
control_stop();
delay();
delay();
delay();
}
P1_15=1;
delay();
while((P1_2==0)|(P1_4==0))
{
control_up();
delay();
control_stop();
delay();
delay();
}
if(sec<30)
{
goto lab;
}//在这段时间内一直在来回调平衡
//state_flag++;
/*else
{
control_stop();
delay();
delay();
delay();
delay();
delay();
}*/
sec=0;//时间从新显示
//while((P1_2==0)&(P1_7==0))
//{
lab4: while((P1_1==0)&(P1_7==0))
{
control_down();//还要测试速度???????????????
}
while(P1_1==1)
{
control_left();
}
while(P1_7==1)
{
control_right();
}
if(P1_1==1)
{
if(P1_7==1)//说明已经到达B端
{
control_stop();
sec=0;
goto lab2;
}
}
else
{
goto lab4;
}
lab2: while(sec<5);//停留5秒
sec=0;
control_goback();//返回A点
lab3: while((P1_0==0)&(P1_6==0))//启用后轮传感器
{
control_goback();//还要测试速度???????????????
}
while(P1_0==1)//还要测试这两个传感器
{
control_left();
}
while(P1_6==1)
{
control_right();
}
if(P1_0==1)
{
if(P1_6==1)
{
control_stop();//说明到达A端
}
}
else
{
goto lab3;
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -