Obstacle Avoidance Robot
Obstacle Avoidance Robot
Name Enrollment
H-11 Campus,Islamabad
Transient Response:
"The transient response of a system is its short-term behaviour immediately following a change in its
input or initial conditions."
"The steady state response of a system is its stable and unchanging behaviour after
Stability of a System:
Stability of a system refers to its ability to maintain its intended behaviour or state over time, even
when subjected to disturbances or changes in its environment. If a system is stable, it will settle into a
predictable and consistent pattern or state after being perturbed, without exhibiting unbounded or divergent
behaviour.
Equation:
As we haven’t designed the robot yet but with simulations done with the code the following are responses
recorded through Python.
import numpy as np
numerator = [1]
denominator = [1, 1, 1]
plt.figure(figsize=(18, 6))
plt.subplot(1, 3, 1)
plt.xlabel('Time')
plt.ylabel('Output')
plt.grid(True)
plt.legend()
steady_state_response = y_step[-1]
plt.subplot(1, 3, 2)
plt.xlabel('Time')
plt.ylabel('Output')
plt.grid(True)
plt.legend()
poles = sys.poles
print("System is stable.")
else:
print("System is unstable.")
plt.subplot(1, 3, 3)
plt.gca().add_artist(unit_circle)
plt.xlabel('Real')
plt.ylabel('Imaginary')
plt.legend()
plt.tight_layout()
plt.show()
Initial Setup:
int Set=15;
void setup(){
Serial.begin(9600);
pinMode(R_S, INPUT);
pinMode(L_S, INPUT);
pinMode(echo, INPUT );
pinMode(trigger, OUTPUT);
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(enB, OUTPUT);
analogWrite(enA, 200);
analogWrite(enB, 200);
pinMode(servo, OUTPUT);
servoPulse(servo, angle); }
servoPulse(servo, angle); }
distance_F = Ultrasonic_read();
delay(500);
void loop(){
distance_F = Ultrasonic_read();
Serial.print("D F=");Serial.println(distance_F);
//if Right Sensor and Left Sensor are at White color then it will call forword function
else{Check_side();}
//if Right Sensor is Black and Left Sensor is White then it will call turn Right function
//if Right Sensor is White and Left Sensor is Black then it will call turn Left function
delay(10);
}
void servoPulse (int pin, int angle){
digitalWrite(pin, HIGH);
delayMicroseconds(pwm);
digitalWrite(pin, LOW);
Ultrasonic_read:
long Ultrasonic_read(){
digitalWrite(trigger, LOW);
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
return time / 29 / 2;
void compareDistance(){
turnLeft();
delay(500);
forword();
delay(600);
turnRight();
delay(500);
forword();
delay(600);
turnRight();
delay(400);
else{
turnRight();
delay(500);
forword();
delay(600);
turnLeft();
delay(500);
forword();
delay(600);
turnLeft();
delay(400);
void Check_side(){
Stop();
delay(100);
servoPulse(servo, angle); }
delay(300);
distance_R = Ultrasonic_read();
Serial.print("D R=");Serial.println(distance_R);
delay(100);
servoPulse(servo, angle); }
delay(500);
distance_L = Ultrasonic_read();
Serial.print("D L=");Serial.println(distance_L);
delay(100);
servoPulse(servo, angle); }
delay(300);
compareDistance();
This code is designed to control a line following and obstacle avoiding robot on Arduino. The software used
will be ARDUINO IDE.
Components Used:
Sensors will be adjusted according to the lights then if both the sensors will be detecting line, the robot will
move forward, if only left sensor detects it’ll turn right, otherwise it’ll turn left. Same goes for the Ultrasonic
sensor. When no line is detected by IR Sensor, the Ultrasonic sensor will detect obstacles. If an obstacle is
detected within 10cm (parameter provided in the code), the robot will stop and will back up, then it’ll turn right
to avoid obstacle.
Circuit Diagram:
Conclusion:
Designing a line-following obstacle avoidance robot requires careful consideration of mechanical design, sensor
selection, and control algorithms. By integrating these elements effectively, the robot can navigate
autonomously while following lines and avoiding obstacles. It's essential to balance simplicity with
functionality to create a robust and efficient robot for real-world applications.
[1]
References
[1] MrElectroUino, "Arduino Obstacle Avoidance Line Follower Robot Projects," [Online]. Available:
https://www.instructables.com/Arduino-Obstacle-Avoidance-Line-Follower-Robot-Pro/.
[2] Mrelectrouino, "Autodesk Instructables," [Online]. Available: https://www.instructables.com/Arduino-
Obstacle-Avoidance-Line-Follower-Robot-Pro/.
[3] J. Zafar, "Line Follower Obstacle Avoiding Robot Using Arduino And L298 Motor Driver," marobotic,
[Online]. Available: https://marobotic.com/2023/10/22/line-follower-obstacle-avoiding-robot-using-
arduino-and-l298-motor-driver/.
--------------------------------------------------------------------------------