fbpx

Obstacle Avoiding Robot

Obstacle avoider robot avoids obstacle in its path.To avoid obstacle first we need to sense the obstacle and second we want to find the way to avoidthe obstacle.

BLOCK DIAGRAM

OBSTACLE AVOIDER ROBOT WORKING

To sense the obstacle in front of the robot we need three IR sensor module,each sensor placed at three different direction:Left,Center,Right.When obstacle is detected by robot then the output of sensor module will be LOW and when it doesn’t detect the obstacle then output is HIGH.

We have eight possible cases when it detects and doesn’t detects the obstacle by robot.

  • When all the three sensors are HIGH,then there is no obstacle so robot  moves forward.
  • When  all the three sensors are LOW,then there is  obstacle present on all three sides and in this case robot goes back and takes a ‘U’ turn.
  • When the Left sensor is LOW,then obstacle is present to the Left side of the robot and in this case robot moves right.
  • When the Right sensor is LOW,then obstacle is present to the Right side of the robot and in this case robot moves Left.
  • When only the Center sensor is LOW,then obstacle is present on the front  of the robot and in this case robot goes back and takes either Left/Right turn.
  • When only the  Left sensor is HIGH,then obstacles are present at both Right and Center side of the robot and in this case robot goes back and turns Left.
  • When only the  Right sensor is HIGH,then obstacles are present at both Left and Center side of the robot and in this case robot goes back and turns Right.
  • When only the  Center sensor is HIGH,then obstacles are present at both Right and Left side of the robot and in this case robot goes back and turns either Left/Right.

Required Components

  1. Bread Board.
  2. Connecting wires.
  3. Castor wheel.
  4. Robot Wheel.
  5. Robot Chasis.
  6. Motor Driver l293d.
  7. DC Geared or BO motor
  8. Arduino
  9. Battery
  10. LM7805
  11. Switch
  12. Capacitors 470uf & 100uf
  13. IR sensor module

Obstacle Avoider Robot LOGIC TABLE

PinMapping

 Between Arduino and L293D

Between Motor and L293D

Between Arduino &  IR Sensors

CIRCUIT DIAGRAM

Software Requirements

1.Arduino ID.

FLOW CHART

PROGRAM

#define RIGHT_MOTOR_ONE 8
#define RIGHT_MOTOR_TWO 9
#define LEFT_MOTOR_ONE 6
#define LEFT_MOTOR_TWO 7

#define L1 2
#define L2 3
#define C 4
#define R1 5
#define R2 6
char Received_Data;

void setup() {
/* IR SENSOR pin configuration */
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(C, OUTPUT);
pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
/* Motor pin configuration */
pinMode(RIGHT_MOTOR_ONE, OUTPUT);
pinMode(RIGHT_MOTOR_TWO, OUTPUT);
pinMode(LEFT_MOTOR_ONE, OUTPUT);
pinMode(LEFT_MOTOR_TWO, OUTPUT);
}

void loop()
{
if (digitalRead(L1) == LOW && digitalRead(L2) == LOW && digitalRead(C) == LOW && digitalRead(R1) == LOW && digitalRead(R2) == LOW)
{
MOVE_ROBOT_REVERSE();
MOVE_ROBOT_UTURN();
}
else if (digitalRead(L1) == HIGH && digitalRead(L2) == HIGH && digitalRead(C) == HIGH && digitalRead(R1) == HIGH && digitalRead(R2) == HIGH)
{
MOVE_ROBOT_FORWARD();
}
else if (digitalRead(L1) == LOW && digitalRead(L2) == LOW && digitalRead(C) == HIGH && digitalRead(R1) == HIGH && digitalRead(R2) == HIGH)
{
MOVE_ROBOT_RIGHT();
}
else if (digitalRead(L1) == HIGH && digitalRead(L2) == HIGH && digitalRead(C) == HIGH && digitalRead(R1) == LOW && digitalRead(R2) == LOW)
{
MOVE_ROBOT_LEFT();
}
else if (digitalRead(L1) == HIGH && digitalRead(L2) == HIGH && digitalRead(C) == LOW && digitalRead(R1) == HIGH && digitalRead(R2) == HIGH)
{
MOVE_ROBOT_REVERSE();
MOVE_ROBOT_RIGHT();
}
else if (digitalRead(L1) == HIGH && digitalRead(L2) == HIGH && digitalRead(C) == LOW && digitalRead(R1) == LOW && digitalRead(R2) == LOW)
{
MOVE_ROBOT_REVERSE();
MOVE_ROBOT_LEFT();
}
else if (digitalRead(L1) == LOW && digitalRead(L2) == LOW && digitalRead(C) == LOW && digitalRead(R1) == HIGH && digitalRead(R2) == HIGH)
{
MOVE_ROBOT_REVERSE();
MOVE_ROBOT_RIGHT();
}
else if (digitalRead(L1) == LOW && digitalRead(L2) == LOW && digitalRead(C) == HIGH && digitalRead(R1) == LOW && digitalRead(R2) == LOW)
{
MOVE_ROBOT_REVERSE();
MOVE_ROBOT_RIGHT();
}
}

/* MOVE ROBOT FORWARD */
void MOVE_ROBOT_FORWARD()
{
digitalWrite(RIGHT_MOTOR_ONE, HIGH);
digitalWrite(RIGHT_MOTOR_TWO, LOW);
digitalWrite(LEFT_MOTOR_ONE, HIGH);
digitalWrite(LEFT_MOTOR_TWO, LOW);
}

/* MOVE ROBOT U-TURN */
void MOVE_ROBOT_UTURN()
{
digitalWrite(RIGHT_MOTOR_ONE, HIGH);
digitalWrite(RIGHT_MOTOR_TWO, LOW);
digitalWrite(LEFT_MOTOR_ONE, LOW);
digitalWrite(LEFT_MOTOR_TWO, HIGH);
delay(3000);
}

/* MOVE ROBOT REVERSE */
void MOVE_ROBOT_REVERSE()
{
digitalWrite(RIGHT_MOTOR_ONE, LOW);
digitalWrite(RIGHT_MOTOR_TWO, HIGH);
digitalWrite(LEFT_MOTOR_ONE, LOW);
digitalWrite(LEFT_MOTOR_TWO, HIGH);
}

/* MOVE ROBOT LEFT */
void MOVE_ROBOT_LEFT()
{
digitalWrite(RIGHT_MOTOR_ONE, HIGH);
digitalWrite(RIGHT_MOTOR_TWO, LOW);
digitalWrite(LEFT_MOTOR_ONE, LOW);
digitalWrite(LEFT_MOTOR_TWO, HIGH);
}

/* MOVE ROBOT RIGHT */
void MOVE_ROBOT_RIGHT()
{
digitalWrite(RIGHT_MOTOR_ONE, LOW);
digitalWrite(RIGHT_MOTOR_TWO, HIGH);
digitalWrite(LEFT_MOTOR_ONE, HIGH);
digitalWrite(LEFT_MOTOR_TWO, LOW);
}

/* STOP ROBOT */
void STOP_ROBOT()
{
digitalWrite(RIGHT_MOTOR_ONE, LOW);
digitalWrite(RIGHT_MOTOR_TWO, LOW);
digitalWrite(LEFT_MOTOR_ONE, LOW);
digitalWrite(LEFT_MOTOR_TWO, LOW);
} 

Leave a Reply

Your email address will not be published. Required fields are marked *