IT GOES NORTH MOST OF THE TIME

Dependencies:   HMC6352 Motor mbed

Revision:
14:9f5ce2fd2cfc
Parent:
13:76a6ce8b2116
Child:
15:ff95ff245fc0
diff -r 76a6ce8b2116 -r 9f5ce2fd2cfc main.cpp
--- a/main.cpp	Wed Oct 10 10:10:25 2012 +0000
+++ b/main.cpp	Wed Oct 10 20:14:15 2012 +0000
@@ -93,7 +93,7 @@
                     NorthOn=0;
                     dir=Left;
                 }
-                else if(((globalDir > 30 && globalDir <= 180)||(globalDir > 180 && globalDir <= 330))&&NorthOn)
+                else if(((globalDir >= 30 && globalDir <= 330))&&NorthOn)
                 
                 {
                             right.speed(0);
@@ -175,10 +175,18 @@
                     dir=Forward;
                 }
                 else
-                {   if(globalDir<=180){
-                    right.speed(1);
-                    left.speed(-1);}
-                    else{right.speed(-1); left.speed(1);}
+                {   
+                    //If it's not going north, choose which way to turn to get north
+                    if(globalDir<=180)
+                    {
+                        right.speed(1);
+                        left.speed(-1);
+                    }
+                    else
+                    {
+                        right.speed(-1);
+                        left.speed(1);
+                    }
                 }
             break;
         }