Project Narrowbot

by udaykarthikeya77 in Circuits > Robots

553 Views, 4 Favorites, 0 Comments

Project Narrowbot

How to make an obstacle avoiding robot using l293d ic

Hey guys , your K day gamer here ! In this instructable page , I am going to show you how I made my obstacle avoiding robot (The Narrowbot)...... So , let's get started !

Gather the Components

IMG_20180414_162519.jpg
images (16).jpeg
images (11).jpeg

You will need the following components to build this ROBOT :

1. Arduino uno

2. Prototyping shield for Arduino uno (optional)

3. Mini bread board ( not required if you have prototyping shield )

4. HC-SR04 Ultrasonic sensor

5. L293d motor driver ic

6. 2 × breadboards

7. Jumper wires

8. An LED

9. Geared motors and wheels

10. 2 × 104 pf capacitors

11. A soldering iron with solder wire and

12 . A caster wheel

13. 2 × 9v batteries with clips ( make sure you have a clip for Arduino and another for breadboard )

Make Your Chassis

IMG_20180520_103727.jpg
IMG_20180520_103738.jpg

To make the chassis for my Narrowbot , I am going to use 2 breadboards so that I can make my motor driving circuit on the breadboard itself ! To make my chassis ,

1. I joined the two breadboards to make a base for my robot .......

2. I soldered 104 pf capacitors and jumper wires to the motors ,

3. glued the motors to the breadboard base ......and

4. Then I glued caster wheel to the Bottom of the base

5. I plugged the wheels to the motors and now , the chassis is done !

Time for Electronics !

images (11).jpeg
images (16).jpeg

# For the electronics , I am using 2 9 volt batteries as power supplies for Arduino and motors !

# Don't worry that Arduino uses only 5 volts , it has a voltage regulator which converts the 9 volt input into 5 volt stable output .....

# I plugged the prototyping shield into Arduino for HC-SR04 ULTRASONIC SENSOR to rest freely on top .

# I the connected it's vcc and ground pins to 5 volts and ground pins on the prototyping shield respectedly .

# Then , I connected it's trig and echo pins to Arduino's digital pins 9 and 10 respectively.

# HC-SR04 connections are done .

# Now let's head to l293d connections !

# see the pin diagram above for reference .

# I plugged in the l293d ic to the breadboard base and made the connections as follows :

# I've connected grounds pins 4 , 5 , 12 , 13 to ground of the Arduino .

# Before I connected the power supply of the motors' to the IC , I added a switch so that it can save power .

# Then , I connected vcc pin of ic ( pin 16 ) to vcc of Arduino and vss pin of ic ( pin 8 ) to 9 volts power supply.

# I then connected the ground of the motors' power supply to ground line in the breadboard.

# I connected the input pins 2,7,10 and 15 of the ic to Arduino's digital pins 2,3,4 and 5 respectively.

# I connected the enable pins 1 and 9 to Arduino's digital pins 5 and 6 respectively.

# Then , I connected the wires from the first motor to pins 3 and 6 of the ic and the wires from the second motor to pins 11 and 14 of the ic.

# just to know if it works or not , I connected an LED to digital pin 13 and ground of the Arduino .

# yay , motor driving circuit is done and now , our whole circuit is complete.

Let's Start Coding !

images (17).jpeg

Down below is the code which was used to program the robot ! You may make a few changes to it or just copy it and paste it in the Arduino editor .if the code doesn't work , try using a different code from online and make a few changes if you want or please comment down below about the errors that showed up in your Arduino software so that I can find a code which may work for you !

Code :

const int trigPin = 9;
const int echoPin = 10;

constint in1 = 2;

const int in2 = 3;

const int in3 = 4;

const int in4 = 5;

Int LED = 13;

void setup() {

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode (in1, OUTPUT);

pinMode(in2, OUTPUT);

pinMode(in3, OUTPUT);

pinMode(in4, OUTPUT);

}

long duration, distance;

void loop() {

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration= pulseIn(echoPin, HIGH);

distance= duration/58.2;

if(distance<30) {

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

digitalWrite(in3, LOW);

digitalWrite(in4, HIGH);

digitalWrite(LED, HIGH);

delay(1200);

}

else {

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

digitalWrite(LED, LOW);

}

delay(0);

}