hasibkyau / Scorpion_2.0_The_Line_Follower_Robot

Line Follwer Robot Version 2
2 stars 0 forks source link

Algorithm to detect choose a path from a junction of black lines. #12

Closed hasibkyau closed 2 years ago

hasibkyau commented 2 years ago
  1. Decide if the car is on the multiple path or not
  2. Choose the best way
  3. Follow the way
hasibkyau commented 2 years ago

void FollowTrack() {

if (AIR == 4)//On track { //(A == 0) ? _90dLeft() : (B == 0) ? MedLeft() : (C == 0 ) ? Straight() : ( D == 0 ) ? MedRight() : _90dRight(); (A == 0) ? HardLeft() : (B == 0) ? MedLeft() : (C == 0 ) ? Straight() : ( D == 0 ) ? MedRight() : HardRight(); } else if (AIR == 3) // { if (B == 0) { //(A == 0) ? SharpLeft() : SmoothLeft();//smooth left for C = 0 and B = 0 (C == 0) ? SmoothLeft() : SharpLeft(); } else if (D == 0) { (C == 0) ? SmoothRight() : SharpRight(); }

} else if (AIR == 2 || AIR == 1) { int temp = A; delay(wrt / 8); ReadIR(); //go 1 cm and read the track (AIR == 0) ? DefaultTurn() : ((temp == 1) ? _90dRight() : _90dLeft()); } else if (AIR == 0)//multiple line { DefaultTurn(); } else if (AIR == 5)// White space { //Serial.println("white space!");delay(500); Straight(); //go 14cm forward delay(wrt); Brake(); // Speed 0 with forward gear

ReadIR();
//ReadSonar();

if (AIR < 5) {
  //Serial.println("Track Found"); delay(500);
  Straight(); // if found track. It was a blank track.
}
else if (AIR == 5) // if no track
{
  //Serial.println("No Track Found! Wall checking"); delay(500);
  if (LeftWall <= 50 && RightWall <= 50) // if no track & found walls
  {
    Serial.println("Wall found!"); delay(500);
    // follow walls until the track is founded
    while (AIR == 5){
      ReadIR();
      PassThroughWalls();
    }
    Serial.println("Released from wall!"); delay(500);
  }
  else if (LeftWall >= 100 && RightWall >= 100) {
    //Serial.println("No track and no wall found!"); delay(1000);
    _180dturn(); //if no track and no Side Walls. The track ends here.
  }
}

} }