1、电赛寻线方案#includefindblack.h#define godelay 10#define stopdelay 40#define turndelay 25sbit beep=P37; char crossnum=0,x=1,y=1,crossflag=0,direction=dx,pingzi12=0;void delay(uint xms) uint i,j; for(i=xms;i0;i-) for(j=110;j0;j-); void find() if(G1=off&G2=off&G3=on&G4=off&G5=off) / 00100 go(100,100); if(G1
2、=off&G2=off&G3=off&G4=on&G5=off) / 00010 go(100,0); if(G1=off&G2=on&G3=off&G4=off&G5=off) / 01000 go(0,100); if(G1=off&G2=off&G3=on&G4=on&G5=off) / 00110 go(100,0); if(G1=off&G2=on&G3=on&G4=off&G5=off) / 01100 go(0,100); if(G1=off&G2=off&G3=off&G4=off&G5=on) / 00001 go(100,0); if(G1=on&G2=off&G3=off
3、&G4=off&G5=off) / 10000 go(0,100); if(G1=on&G2=on&G3=on&G4=on&G5=on) / 11111 go(100,100); delay(godelay); go(0,0);beep=0; delay(stopdelay);beep=1; crossflag=1; if(G1=on&G2=on&G4=off&G5=off) / 11*00 go(100,100); delay(godelay); go(0,0);beep=0; delay(stopdelay);beep=1; crossflag=1; if(G1=off&G2=off&G4
4、=on&G5=on) / 00*11 go(100,100); delay(godelay); go(0,0);beep=0; delay(stopdelay);beep=1; crossflag=1; if(G1=off&G2=off&G3=off&G4=off&G5=off) / 00000 go(50,50); void zoufangge() find(); / WriteString(x=,0,0); WriteChar(x+48,2,0);/ WriteString(,y=,3,0); WriteChar(y+48,6,0);/ if(direction=dy)/ WriteStr
5、ing(,dir=y,7,0); / if(direction=dfy)/ WriteString(,dir=-y,7,0); / if(direction=dx)/ WriteString(,dir=x,7,0); / if(direction=dfx)/ WriteString(,dir=-x,7,0); if(down1=0|down2=0|down3=0) /正立瓶子 left_turn_90_degree(); if(direction=dx) direction=dy; else if(direction=dy) direction=dfx; else if(direction=d
6、fx) direction=dfy; else if(direction=dfy) direction=dx; else if(up1=0|up2=0|up3=0) /倒立瓶子 right_turn_90_degree(); if(direction=dx) direction=dfy; else if(direction=dy) direction=dx; else if(direction=dfx) direction=dy; else if(direction=dfy) direction=dfx; if(crossflag=1) crossflag=0; if(direction=dx
7、)x+; else if(direction=dfx)x-; else if(direction=dy)y+; else if(direction=dfy)y-; if(x=6&y=3) go(0,0); while(1); if(x=1&y=1) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=2&y=1) if(directi
8、on=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=3&y=1) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direct
9、ion=dy; if(x=4&y=1) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=5&y=1) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx)
10、right_turn_90_degree(); direction=dy; if(x=6&y=1) if(direction=dy) /go if(direction=dx) left_turn_90_degree(); direction=dy; if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=1&y=2) if(direction=dy) /go if(direction=dx) /go if(directi
11、on=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=2&y=2) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=3&y=2) if(direction=dy) /go i
12、f(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=4&y=2) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x
13、=5&y=2) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=6&y=2) if(direction=dy) /go if(direction=dx) left_turn_90_degree(); direction=dy; if(direction=dfy) / if(direction=dfx) / if(x=1&y=3)
14、if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dfx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=2&y=3) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_t
15、urn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=3&y=3) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dfx; if(x=4&y=3) i
16、f(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=5&y=3) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_tur
17、n_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=6&y=3) if(x=0&y=1) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=0&y=2) if(direction=dy) /go if(di
18、rection=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=0&y=3) if(direction=dy) /go if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=0&y
19、=4) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=1&y=4) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) lef
20、t_turn_90_degree(); direction=dfx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=2&y=4) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dfx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=3&y=
21、4) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=4&y=4) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) left_turn_90_degree(); direction=dx; if(direction=dfx) right_turn_90_degree(); direction=dy; if(x=5&y=4) if(direction=dy) right_turn_90_degree(); direction=dx; if(direction=dx) /go if(direction=dfy) /go if(direction=dfx) right_turn_90_degree(); direction=dy;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1