hasibkyau / Scorpion_2.0_The_Line_Follower_Robot

Line Follwer Robot Version 2
2 stars 0 forks source link

Algorithm to detect Blank space on the track or end of the track or side wall on the track and make a perfect decison.. #13

Closed hasibkyau closed 2 years ago

hasibkyau commented 2 years ago

Write code to:

  1. If the track has a short blank space the car will move forward.
  2. If the car is on end of the track and no side wall detected the car will turn 180 degree and will find another way
  3. If the car is on end of the track and found side walls the car will cross the wall by the middle side of both wall
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.
  }
}

} }