ASEE-2014 / LineFollower

Dependents:   ASEE-2014

Fork of LineFollower by Christopher Bradford

Revision:
8:12751953ad8e
Parent:
7:de9902f316aa
Child:
9:039a74519b89
diff -r de9902f316aa -r 12751953ad8e LineFollower.cpp
--- a/LineFollower.cpp	Sun Mar 09 23:55:34 2014 +0000
+++ b/LineFollower.cpp	Mon Mar 10 00:03:42 2014 +0000
@@ -36,12 +36,12 @@
     int LineFollower::followLine(Motor l, Motor r){
            int count = 0;
            for(int i = 0; i<8; i++){
-                count += (array&(1<<0))?0:1;  
+                count += (array&(1<<i))?0:1;  
             }
             
             switch(count){
                 
-                case 7: if(this->read() == 0x7F){
+                case 1: if(this->read() == 0x7F){
                             l.speed(-(0.75 * MAXSPEED));
                             r.speed(MAXSPEED);
                         }
@@ -51,7 +51,7 @@
                         }
                         break;
                         
-                case 6: if(this->read() == 0xE7){
+                case 2: if(this->read() == 0xE7){
                             l.speed(MAXSPEED);
                             r.speed(MAXSPEED);
                         }
@@ -81,7 +81,7 @@
                         }
                         break;
                         
-                case 5: if(this->read() == 0x1F){
+                case 3: if(this->read() == 0x1F){
                             l.speed(-(0.25*MAXSPEED));
                             r.speed(MAXSPEED);
                         }