Welcome to Kerala Project Center.

Arduino Based Obstacle Avoiding Robot Car

Arduino Based Obstacle Avoiding Robot Car

This obstacle avoiding machine uses an HC-SR04 sensor mounted on top of a servo to locate walls in a maze using echolocation. The 4 DC motors are powered by a 9V battery back that runs from an L298 chip. The Arduino, servo, and sensor are powered by a separate 9V battery. The car moves forward until it sees a wall that is less than 35cm away. If this condition is met, the car backs up and the servo rotates 90 degrees to the left for the sensor to scan how far away the left wall is. The servo then rotates 180 degrees to the right to scan the distance of the right wall. If the distance of the left wall is more than the right, the car will turn 90 degrees to the left, and vice versa. This project was fun to make! There are a few 3d printed parts, but none of them are fundamental.

Components




Arduino
L298 Motor Driver
Ultrasonic sensor
12V DC motor
9V Battery
Car chasis
servo motor


Components Hexkart Flipkart
Arduino Buy Now Buy Now
L298 Motor Driver Buy Now Buy Now
Ultrasonic Sensor Buy Now Buy Now
12V DC motor Buy Now Buy Now
Servo motor Buy Now Buy Now
Car Chasis Buy Now Buy Now




Arduino



Arduino is an open source electronic prototyping platform.Arduino board designs use a variety of microprocessors and controllers. The boards are equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to various expansion boards ('shields') or breadboards (for prototyping) and other circuits. The boards feature serial communications interfaces, including Universal Serial Bus (USB) on some models, which are also used for loading programs. The microcontrollers can be programmed using the C and C++ programming languages, using a standard API which is also known as the Arduino language, inspired by the Processing language and used with a modified version of the Processing IDE.



Ultrasonic Sensor



An ultrasonic sensor is an electronic device that measures the distance of a target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal. Ultrasonic waves travel faster than the speed of audible sound (i.e. the sound that humans can hear). Ultrasonic sensors have two main components: the transmitter (which emits the sound using piezoelectric crystals) and the receiver (which encounters the sound after it has travelled to and from the target).Ultrasonic sensors are used primarily as proximity sensors. They can be found in automobile self-parking technology and anti-collision safety systems. Ultrasonic sensors are also used in robotic obstacle detection systems, as well as manufacturing technology. In comparison to infrared (IR) sensors in proximity sensing applications, ultrasonic sensors are not as susceptible to interference of smoke, gas, and other airborne particles (though the physical components are still affected by variables such as heat).Ultrasonic sensors are also used as level sensors to detect, monitor, and regulate liquid levels in closed containers (such as vats in chemical factories). Most notably, ultrasonic technology has enabled the medical industry to produce images of internal organs, identify tumors, and ensure the health of babies in the womb.



L298 Motor Driver



It is a high voltage, high current dual full-bridge driver designed to accept standard TTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable or disable the device independently of the input signals. The emitters of the lower transistors of each bridge are connected together and the corresponding external terminal can be used for the con-nection of an external sensing resistor. An additional supply input is provided so that the logic works at a lower voltage.
They are mostly used when

  • It is needed to operate different loads like motors and solenoid etc where an H-Bridge is required.
  • High power motor driver is required.
  • Control unit can only provide TTL outputs.
  • Current control and PWM operable single-chip device are needed.



Servo Motor



Micro Servo Motor SG90 is a tiny and lightweight server motor with high output power. Servo can rotate approximately 180 degrees (90 in each direction), and works just like the standard kinds but smaller. You can use any servo code, hardware or library to control these servos. Good for beginners who want to make stuff move without building a motor controller with feedback & gear box, especially since it will fit in small places. It comes with a 3 horns (arms) and hardware.



Circuit Diagram






Arduino Code




#include
#include
int LeftSideForward = 3;
int LeftSideBackward = 4;
int RightSideForward = 2;
int RightSideBackward = 7;
int SpeedRight = 5;
int SpeedLeft = 6;
int trigPin = A2;
int echoPin = A1;
long duration, cm, inches;
int maximumcm = 250;
NewPing sonar(trigPin, echoPin, maximumcm);
Servo servo_motor;
void setup(){
pinMode(RightSideForward, OUTPUT);
pinMode(LeftSideForward, OUTPUT);
pinMode(LeftSideBackward, OUTPUT);
pinMode(RightSideBackward, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
servo_motor.attach(8); //our servo pin
servo_motor.write(115);
delay(2000);
cm = readPing();
delay(100);
cm = readPing();
delay(100);
cm = readPing();
delay(100);
cm = readPing();
delay(100);
Serial.begin(9600);
}
void loop(){
cm = readPing();
int cmRight = 0;
int cmLeft = 0;
delay(50);
if (cm < 35){
Serial.println(cm);
Stop();
delay(300);
Backward();
delay(550);
Stop();
delay(300);
cmRight = lookRight();
Serial.println(cmRight);
delay(300);
cmLeft = lookLeft();
Serial.println(cmLeft);
delay(300);
Stop();
delay(300);
if (cmLeft < 20 && cmRight < 20)
{
Serial.println(cm);
Stop();
delay(300);
Backward();
delay(1300);
Stop();
delay(300);
cmRight = lookRight();
Serial.println(cmRight);
delay(300);
cmLeft = lookLeft();
Serial.println(cmLeft);
delay(300);
Stop();
delay(300);
}
else if (cmLeft > cmRight){
Right();
delay(520);
Stop();
}
else if (cmRight > cmLeft)
{
Left();
delay(510);
Stop();
}
}
else
{
Forward();
}
cm = readPing;
}
//FUNCTIONS
int lookRight(){
servo_motor.write(0);
delay(500);
int cm = readPing();
delay(300);
servo_motor.write(90);
return cm;
delay(150);
}
int lookLeft(){
servo_motor.write(180);
delay(500);
int cm = readPing();
delay(300);
servo_motor.write(90);
return cm;
delay(150);
}
int readPing(){
delay(70);
int cm = sonar.ping_cm();
if (cm==0){
cm=250;
}
return cm;
delay(150);
}
void Stop(){
digitalWrite(LeftSideForward, LOW);
digitalWrite(LeftSideBackward, LOW);
digitalWrite(RightSideForward, LOW);
digitalWrite(RightSideBackward, LOW);
}
void Forward()
{
Serial.println("Forward");
digitalWrite(LeftSideForward, HIGH);
digitalWrite(LeftSideBackward, LOW);
digitalWrite(RightSideForward, HIGH);
digitalWrite(RightSideBackward, LOW);
analogWrite(SpeedRight, 75);
analogWrite(SpeedLeft, 75);
}
void Backward()
{
Serial.println("Backward");
digitalWrite(LeftSideForward, LOW);
digitalWrite(LeftSideBackward, HIGH);
digitalWrite(RightSideForward, LOW);
digitalWrite(RightSideBackward, HIGH);
analogWrite(SpeedRight, 75);
analogWrite(SpeedLeft, 75);
}
void Right()
{
Serial.println("Right");
digitalWrite(LeftSideForward, HIGH);
digitalWrite(LeftSideBackward, LOW);
digitalWrite(RightSideForward, LOW);
digitalWrite(RightSideBackward, HIGH);
analogWrite(SpeedRight, 105);
analogWrite(SpeedLeft, 105);
}
void Left()
{
Serial.println("Left");
digitalWrite(LeftSideForward, LOW);
digitalWrite(LeftSideBackward, HIGH);
digitalWrite(RightSideForward, HIGH);
digitalWrite(RightSideBackward, LOW);
analogWrite(SpeedRight, 105);
analogWrite(SpeedLeft, 105);
}




Hours

Monday - Saturday: 9:00 AM - 5:00 PM
Sunday: Not Working

Location

Door No. 510, Samastha Jubilee Memorial Soudham,
Mele thampanoor, Trivandrum, Kerala – 695001

Book Now

+91 9633118080