Introduction: BASIC ARDUINO OBSTACLE AVOIDANCE ROBOT

Create a simple arduino based obstacle avoidance robot

Step 1: REQUIREMENTS

MATERIALS REQUIRED


1. Ofcourse Arduino Uno (any other compatible board) X 1

2. Chasis for robot ( i used one from my brother's RC car )

3. A L293D Dual h-bridge ic

4. A custom circuit board for the ic ( reduced the making cost instead for going for the sheild )

5. Screws and spacers

6. A Geared motor pair ( i got it from amazon with wheels)

7. HC-SR04 ULTRASONIC SENSOR

8. A PC for programming arduino

9. A battery ( li-po will be better)

Step 2: INTRODUCTION TO L293D IC

L293D Description

L293D is a typical Motor driver or Motor Driver IC which allows DC motor to drive on either direction. L293D is a 16-pin IC which can control a set of two DC motors simultaneously in any direction. It means that you can control two DC motor with a single L293D IC. Dual H-bridge Motor Driver integrated circuit (IC).

The l293d can drive small and quiet big motors as well

Concept

It works on the concept of H-bridge. H-bridge is a circuit which allows the voltage to be flown in either direction. As you know voltage need to change its direction for being able to rotate the motor in clockwise or anticlockwise direction, Hence H-bridge IC are ideal for driving a DC motor.

In a single L293D chip there are two h-Bridge circuit inside the IC which can rotate two dc motor independently. Due its size it is very much used in robotic application for controlling DC motors.

There are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive the motor, the pin 1 and 9 need to be high. For driving the motor with left H-bridge you need to enable pin 1 to high. And for right H-Bridge you need to make the pin 9 to high. If anyone of the either pin1 or pin9 goes low then the motor in the corresponding section will suspend working. It’s like a switch.

TIP: you can simply connect the pin16 VCC (5v) to pin 1 and pin 9 to make them high.

 

Working of L293D

There are 4 input pins for l293d, pin 2,7 on the left and pin 15 ,10 on the right as shown on the pin diagram. Left input pins will regulate the rotation of motor connected across left side and right input for motor on the right hand side. The motors are rotated on the basis of the inputs provided across the input pins as LOGIC 0 or LOGIC 1.

In simple you need to provide Logic 0 or 1 across the input pins for rotating the motor.

L293D Logic Table.

Lets consider a Motor connected on left side output pins (pin 3,6). For rotating the motor in clockwise direction the input pins has to be provided with Logic 1 and Logic 0.   

• Pin 2 = Logic 1 and Pin 7 = Logic 0 | Clockwise Direction
• Pin 2 = Logic 0 and Pin 7 = Logic 1 | Anticlockwise Direction
• Pin 2 = Logic 0 and Pin 7 = Logic 0 | Idle [No rotation] [Hi-Impedance state]
• Pin 2 = Logic 1 and Pin 7 = Logic 1 | Idle [No rotation]

In a very similar way the motor can also operate across input pin 15,10 for motor on the right hand side.

for more info you can visit ron robotics
 

Step 3: CIRCUIT DIAGRAM

The connection diagram is pretty straight forward

The motor will be controlled by the arduino through digital pins by changing the output state.

The direction of motor will be determined by distance measured by ultrasonic sensor

Step 4: BUILDING ROBOT AND CODDING

1.Attach the circuit board and arduino as stack on the screws and mount it into the chasis

2. Connect the motors and wiring according to the circuit mentioned earlier

3. Mount the HC SR04 sensor at the front of chasis and connect it to arduino

4. Upload the arduino sketch and youre ready to go...



Step 5: CODE

This is a basic code for obstacle avoidance robot.
You can modify it to do various things like adding a servo to scan the surrounding and making the robot to move to longest path.But since i'm building the simplest robot i'm not going to that..



int maximumRange = 30;
long duration, distance;

void setup() {
  Serial.begin (9600);
  pinMode (trigpin, OUTPUT);
  pinMode (echopin, INPUT );
  pinMode (4, OUTPUT);
  pinMode (5, OUTPUT);
  pinMode (13, OUTPUT);
  pinMode (6, OUTPUT);
  pinMode (7, OUTPUT);
}

void loop ()
{

  {
    digitalWrite(trigpin,LOW);
    delayMicroseconds(2);
    
    digitalWrite(trigpin,HIGH);
    delayMicroseconds(10);
    
    duration=pulseIn (echopin,HIGH);
    
    distance= duration/58.2;
    delay (50);
    Serial.println(distance);
  }
  
  if (distance >= 30 ){
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
    digitalWrite(6,LOW);
    digitalWrite(7,LOW);
    delay (200);
  }
  
  else if (distance >=15 && distance     digitalWrite (4,HIGH);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    digitalWrite (7,LOW);
    delay (1000);
  }
 else if (distance < 15){
   digitalWrite (4, LOW);
   digitalWrite (5, LOW);
   digitalWrite (6,HIGH);
   digitalWrite (7,HIGH);
   delay (1000);
   digitalWrite (4,LOW);
   digitalWrite (5,HIGH);
   digitalWrite (6,LOW);
   digitalWrite (7, LOW);
   delay (1000);
   
     
 }

}

Comments

About This Instructable

789views

6favorites

License:

Bio: I am an engineering student who is very passionate about technology. I like to code a lot, build projects and I am very curious of ... More »
More by ANANTHA KRISHNAN J:DIY Amazon EchoIot Based Home Automation System With Speech RecognitionBASIC ARDUINO OBSTACLE AVOIDANCE ROBOT
Add instructable to: