void putfire_3(void)//房间 3 灭火
{
int j=0,k=0;//j 接收最大火焰对应通道
k=EyeChMaxEx(EYE_0);
while((AI(4)>AI4)||(j!=5))//利用火焰传感器和机器人正对传感器
(AI(4)/AI(9))作为标准
{
j= EyeChMaxEx(EYE_0);
if(j==5)
{
SetMoto_stright(30,30);//正对火焰直行
}
else if(j<5)
{
SetMoto_left(60,5);//在左边左拐
}
else if((j>5)&&(j<=10))//在右边右拐
{
SetMoto_right(5,60);
}
}
SetMoto_stright(0,0);
beep(1);//启动蜂鸣器
SetMoto(2,100);//启动风扇
wait(2);
beep(0);//关闭蜂鸣器
SetMoto(2,0);//关闭风扇
if(k>8)
SetMoto_left(30,10);
wait(0.13);
while(AI(1)>AI1)
{
if(AI(0)
AI9)//前面无墙
{
if((AI(10)>AI10)&&(AI(11)>AI11))//右边无墙
{
SetMoto_right(0,-50);
}
else if((AI(10)else//直行
{
SetMoto_stright(-30,-30);
}
}
else//前面有墙
{
if((AI(10)>AI10)&&(AI(11)>AI11))//右边无墙
{
SetMoto_right(0,-50);
}
else if((AI(10)
1.86)
{
break;
}
left_home3();
}
while(AI(1)>AI1)
{
left_home3_after();
}
while(1)
{
SetMoto_stright(0,0);
}
}
void left_home3(void)//房间 3 回家沿左墙
{
if(AI(9)>AI9)//前面无墙
{
if((AI(7)>AI7)&&(AI(8)>AI8))//左边无墙
{
SetMoto_left(-35,-10);
}
else//左边有墙
{
SetMoto_right(-5,-45);
}
}
else//前面有墙
{
SetMoto_left(-50,-5);
}
}
void left_home3_after(void)//房间 3 回家沿左墙
{
if(AI(9)>AI9)//前面无墙
{
if((AI(7)>AI7)&&(AI(8)>AI8))//左边无墙
{
SetMoto_left(-35,-10);
}
else if((AI(7)
AI7)&&(AI(8)>AI8))//左边无墙
{
SetMoto_left(-35,-10);
}
else if((AI(7){
SetMoto_right(-5,-45);
}
else//左边有墙
{
SetMoto_stright(-30,-30);
}
}
}
void go_room2(void)//从房间 3 到房间 2
{
t1=seconds();
while(1)
{
t2=seconds();
if(t2-t1>1.06)
{
break;
}
right_wall2();
}
while(AI(1)>AI1)
{
right_wall2_1();//沿右墙到房间 2
}
SetMoto_stright(0,0);
wait(0.08);
}
void right_wall2()//沿右墙到房间 2(调用系统时间)
{
if(AI(9)>AI9)//前面无墙
{
if((AI(10)>AI10)&&(AI(11)>AI11))//右边无墙
{
SetMoto_right(-30,-70);
}
else if((AI(10)
}
}
else//前面有墙
{
SetMoto_left(-80,-5);
}
}
void right_wall2_1()//调用系统时间后到房间 2
{
if(AI(9)>AI9)//前面无墙
{
if((AI(10)>AI10)&&(AI(11)>AI11))//右边无墙
{
SetMoto_right(-30,-70);
}
else if((AI(10)
AI10)&&(AI(11)>AI11))//右边无墙
{
SetMoto_right(-30,-70);
}
else if((AI(10)