A LineFollower library for ASEE-2014
Diff: LineFollower.cpp
- Revision:
- 2:7a4179249fa4
- Parent:
- 1:c319e24af8df
--- a/LineFollower.cpp Fri Feb 21 04:40:34 2014 +0000 +++ b/LineFollower.cpp Fri Feb 21 04:54:56 2014 +0000 @@ -36,7 +36,7 @@ uint8_t LineFollower::read(){ uint8_t binary = 0; int multi = 1; - for(int i=0; i<=8; i++){ + for(int i=0; i<8; i++){ binary += array[i]*multi; multi = multi*2; } @@ -57,68 +57,68 @@ switch(count){ case 1: if(this->read() == 0b10000000){ - l = -(0.75 * MAXSPEED); - r = MAXSPEED; + l.speed(-(0.75 * MAXSPEED)); + r.speed(MAXSPEED); } else if(this->read() == 0b00000001){ - l = MAXSPEED; - r = -(0.75 * MAXSPEED); + l.speed(MAXSPEED); + r.speed(-(0.75 * MAXSPEED)); } break; case 2: if(this->read() == 0b00011000){ - l = MAXSPEED; - r = MAXSPEED; + l.speed(MAXSPEED); + r.speed(MAXSPEED); } else if(this->read() == 0b11000000){ - l = -(0.5 * MAXSPEED); - r = MAXSPEED; + l.speed(-(0.5 * MAXSPEED)); + r.speed(MAXSPEED); } else if(this->read() == 0b00000011){ - l = MAXSPEED; - r = -(0.5 * MAXSPEED); + l.speed(MAXSPEED); + r.speed(-(0.5 * MAXSPEED)); } else if(this->read() == 0b01100000){ - l = 0; - r = MAXSPEED; + l.speed(0); + r.speed(MAXSPEED); } else if(this->read() == 0b00000110){ - l = MAXSPEED; - r = 0; + l.speed(MAXSPEED); + r.speed(0); } else if(this->read() == 0b00110000){ - l = 0.5*MAXSPEED; - r = MAXSPEED; + l.speed(0.5*MAXSPEED); + r.speed(MAXSPEED); } else if(this->read() == 0b00001100){ - l = MAXSPEED; - r = 0.5*MAXSPEED; + l.speed(MAXSPEED); + r.speed(0.5*MAXSPEED); } break; case 3: if(this->read() == 0b11100000){ - l = -(0.25*MAXSPEED); - r = MAXSPEED; + l.speed(-(0.25*MAXSPEED)); + r.speed(MAXSPEED); } else if(this->read() == 0b00000111){ - l = MAXSPEED; - r = -(0.25*MAXSPEED); + l.speed(MAXSPEED); + r.speed(-(0.25*MAXSPEED)); } else if(this->read() == 0b01110000){ - l = 0.25*MAXSPEED; - r = MAXSPEED; + l.speed(0.25*MAXSPEED); + r.speed(MAXSPEED); } else if(this->read() == 0b00001110){ - l = MAXSPEED; - r = .25*MAXSPEED; + l.speed(MAXSPEED); + r.speed(0.25*MAXSPEED); } else if(this->read() == 0b00111000){ - l = 0.5*MAXSPEED; - r = MAXSPEED; + l.speed(0.5*MAXSPEED); + r.speed(MAXSPEED); } else if(this->read() == 0b00011100){ - l = MAXSPEED; - r = 0.5*MAXSPEED; + l.speed(MAXSPEED); + r.speed(0.5*MAXSPEED); } break default: break;