IT GOES NORTH MOST OF THE TIME
Dependencies: HMC6352 Motor mbed
Diff: main.cpp
- Revision:
- 10:168a1b176c77
- Parent:
- 9:6d663bdfee7c
- Child:
- 11:0fd03f66af0d
diff -r 6d663bdfee7c -r 168a1b176c77 main.cpp --- a/main.cpp Wed Oct 10 07:48:36 2012 +0000 +++ b/main.cpp Wed Oct 10 08:22:18 2012 +0000 @@ -69,8 +69,6 @@ switch(dir){ case Forward: - //if(stable[0][0]<35||stable[0][1]<35)||stable[1][0]<35||stable[1][1]<35); NorthOn=0; - if ((avgFront<35&&stable[4][0]<35&&stable[4][1]<35)/*&&stable[4][2]<35&&stable[4][3]<35)*/|| (diagLeft<35&&stable[2][0]<35&&stable[2][1]<35/*&&stable[2][2]<35&&stable[2][3]<35)*/ /*(avgLeft<40&&stable[0][0]<40&&stable[0][1]<40&&stable[0][2]<40&&stable[0][3]<40)*/)) @@ -92,10 +90,8 @@ NorthOn=0; dir=Left; } - else if( - (((globalDir > 30 && globalDir <= 180)||(globalDir > 180 && globalDir <= 330)&&NorthOn) - ) - ) + else if(((globalDir > 30 && globalDir <= 180)||(globalDir > 180 && globalDir <= 330))&&NorthOn) + { right.speed(0); left.speed(0); @@ -103,6 +99,8 @@ } else {right.speed(0.95); left.speed(1); printf("CHARGE!\n\r"); + if((avgLeft<35&&stable[0][0]<35&&stable[0][1]<35) + &&(avgRight<35&&stable[1][0]<35&&stable[1][1]<35)) NorthOn=1; } break; case Right: @@ -150,6 +148,17 @@ break; case TurnNorth: printf("TO THE NORTH!\n\r"); + if( + (avgLeft<35||stable[0][0]<35||stable[0][1]<35) + || + (avgRight<35||stable[1][0]<35||stable[1][1]<35) + || + (diagLeft<35||stable[2][0]<35||stable[2][1]<35) + || + (diagRight<35||stable[3][0]<35||stable[3][1]<35) + || + (avgFront<35||stable[4][0]<35||stable[4][1]<35) + if (globalDir>330 || globalDir < 30) { //It's going north!!