Obstacle Avoidance Robot

This file exchange is about an Obstacle Avoidance Robot algorithm designed in Simulink and Stateflow.
316 Downloads
Updated 10 Mar 2022

View License

The Robot utilizes the ultrasonic sensor HC-Sr04 module to detect the obstacles. The ultrasonic sensor is mounted on the servo motor. If a obstacle is detected, the Robot stops the motion and scans in the left and right directions to the Robot. This scanning motion is achieved by rotating the servo motor in 0 and 180 degrees.
The following motion is achieved based on the conditons
Move Forward:
No obstacle is found in front of the robot
Move Left:
Obstacle detected in front of the robot. Robot Stops. Robot scans in left and right, If the left distance sensor feedback is greater than the right and the left distance from the sensor feedback is greater than the threshold distance, the Robot will turn left
Move Right:
Obstacle detected in front of the robot. Robot scans in left and right, If the right distance sensor feedback is greater than the left and the right distance from the sensor feedback is greater than the threshold distance, the Robot will turn right
Move Reverse:
Obstacle is detected, Robot Stops and rotate's the servo motor left and right to look for obstacles.
If the both left and right distance from the sensor feedback is less than threshold dsitance, the Robot moves in the reverse direction for threshold time.
Hardware Used:
Ultrasonic Sensor
Servo motor
DC Geared motors - 4Nos
L293D H bridge
Arduino UNO
3.7V Lion battery - 2Nos
Hardware Connection(Sensor/Components -> Ardunio)
  1. UltraSonic Sensor Echo Pin - D2
  2. UltraSonic Sensor Trig Pin - D4
  3. ServoMotor Signal Pin - D9
  4. HBridge In1 - D5(Left motor +ve)
  5. HBridge In2 - D6(Left motor -ve)
  6. HBridge In3 - D7(Right motor +ve)
  7. HBridge In3 - D8(Right motor -ve)
MATLAB tools used:
  1. Simulink
  2. Stateflow
  3. Simulink Support Package for Arduino Hardware
Your valuable feedback/comments will be appreciated

Cite As

Ajay Krishna Vasanthakumar (2024). Obstacle Avoidance Robot (https://www.mathworks.com/matlabcentral/fileexchange/107699-obstacle-avoidance-robot), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with R2016b and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.2

Added additional description about the working of the Robot

1.0.1

Added hardwre connection in Description

1.0.0