Sunteți pe pagina 1din 16

OBSTACLE DETECTION/BLUETOOTH

CONTROLLED CAR
EE Semester 2
Section -B

Group Members

NAME

Roll Number

AHMED RAZA MEHMOOD

EE-1133

ABUZAR RIZVI

EE-1122

M YOUSHA

EE-1139

The project has basically two different functions:


1- Obstacle avoidance
2- Bluetooth controlling
However, due to lack of technical experience we were unable to implement
both of functions together, we can operate our car on only one of the above
functions.
Both functions have their respective advantages and disadvantages, so the
purpose it is to use this in different environment where on function fails to
use, (for example in public area, obstacle detector car would not be feasible ,
because the movement of person would cause the detector to read the data.)
and the situations where there is no obstacle in the straight path and we
would be giving signals from the Bluetooth , this would not be effective,
because there would not be any need to manually operate for such scenario.

COMPONENTS USED IN THE PROJECT


1- ARDUINO UNO

The Uno is a microcontroller board based on the ATmega328P. It has 14


digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP
header and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it
with a AC-to-DC adapter or battery to get started.

2- BLUETOOTH MODULE HC-05

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module,
designed for transparent wireless serial connection setup.
Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced
Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and
baseband. It uses CSR Bluecore 04-External single chip Bluetooth system
with CMOS technology and with AFH(Adaptive Frequency Hopping Feature). It
has the footprint as small as 12.7mmx27mm
Specifications
Hardware Features

Typical -80dBm sensitivity

Up to +4dBm RF transmit power

Low Power 1.8V Operation ,1.8 to 3.6V I/O

PIO control

UART interface with programmable baud rate

With integrated antenna

With edge connector

3- L298N MOTOR DRIVER


The L298 is an integrated monolithic circuit in a 15- lead Multiwatt and
PowerSO20 packages. It is a high voltage, high current dual fullbridge driver de- signed to accept standard TTL logic levels and drive
inductive loads such as relays, solenoids, DC and stepping motors.
Follow the steps below to configure the motor controller board to work as a
typical robot motor driver for use with two DC motors.
1. Attach your robots motors to the green Motor A and Motor B screw
terminals.
2. Connect the ENA and ENB to PWM capable digital outputs on your
robots microcontroller.
3. Connect the IN1, 2, 3 and 4 pins to any digital outputs your robots
microcontroller.
4. Apply 5-16V to the board by connecting positive (+) to the blue VMS
screw terminal and ground (-) to the blue GND screw terminal.
5. See below for details on controlling the motors with your robots
microcontroller.

4- ULTRASONIC SENSOR HC-SR04


The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object
like bats do. It offers excellent non-contact range detection with high
accuracy and stable readings in an easy-to-use package. From 2cm to 400
cm or 1 to 13 feet. It operation is not affected by sunlight or black material
like Sharp rangefinders are (although acoustically soft materials like cloth
can be difficult to detect). It comes complete with ultrasonic transmitter and
receiver module.
Features

Power Supply :+5V DC

Quiescent Current : <2mA

Working Current: 15mA

Effectual Angle: <15

Ranging Distance : 2cm 400 cm/1 13ft

Resolution : 0.3 cm

Measuring Angle: 30 degree

Trigger Input Pulse width: 10uS

Dimension: 45mm x 20mm x 15mm

Pins

VCC: +5VDC

Trig : Trigger (INPUT)

Echo: Echo (OUTPUT)

GND: GND

5- DC MOTOR
A DC motor is any of a class of electrical machines that converts direct
current electrical power into mechanical power. The most common types
rely on the forces produced by magnetic fields.

SCHEMATIC

FOR BLUETOOTH CONTROLLED SYSTEM

FOR OBSTACLE DETECTION SYSTEM

PROGRAMMING
CODE FOR BLUETOOTH CONTROLLED SYSTEM
#include<SoftwareSerial.h>

int trig=3;
int echo=2;
int in1=9;
int in2=10;
int in3=5;
int in4=6;
int EnA=8;
int EnB=7;
int led=13;

int IB=0;

void setup(){
Serial.begin(9600);

pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
pinMode(led,OUTPUT);
pinMode(EnA,OUTPUT);
pinMode(EnB,OUTPUT);
}

void loop(){
if(Serial.available()>0){
IB=Serial.read();}

switch(IB)
{
case 'F':
{move_forward();}
break;
case 'B':
{move_backward();}

break;
case 'R':
{move_right();}
break;
case 'L':
{move_left();}
break;
case 'S':
{stoprobo();}
break;

void move_forward(){
analogWrite(EnA,255);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
analogWrite(EnB,255);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println("FORWARD");
}

void move_backward(){
analogWrite(EnA,255);
digitalWrite(in1,LOW);

digitalWrite(in2,HIGH);
analogWrite(EnB,255);
digitalWrite(in3,LOW);
digitalWrite(in4,HIGH);
Serial.println("BACKWARD");

void move_left(){
analogWrite(EnA,0);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
analogWrite(EnB,180);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println("LEFT");
}
void move_right(){
analogWrite(EnA,180);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
analogWrite(EnB,0);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
Serial.println("RIGHT");
}
void stoprobo(){
analogWrite(EnA,0);

digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
analogWrite(EnB,0);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
Serial.println("STOP");
}

CODE FOR OBSTACLE DETECTION


int trig=3;
int echo=2;

int in1=5;
int in2=6;
int in3=7;
int in4=8;
int EnA=4;
int EnB=9;

void setup(){
Serial.begin(9600);

pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);

pinMode(trig,OUTPUT);
pinMode(echo,INPUT);

pinMode(EnA,OUTPUT);
pinMode(EnB,OUTPUT);
}

void loop(){
long distance,duration;
long rdistance,ldistance;
move_forward();
digitalWrite(trig, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trig, HIGH);

delayMicroseconds(10); // Added this line


digitalWrite(trig, LOW);

duration=pulseIn(echo,HIGH);
distance=duration/58;
Serial.print("distance : ");
Serial.println(distance);
if(distance<30){
stoprobo();
delay(1000);

// checks whether there is an obstacle in the specified range.

move_right();
delay(500);
stoprobo();
delay(500);

}
else {
move_forward();
}

//Function declaration
void move_forward(){
analogWrite(EnA,255);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
analogWrite(EnB,255);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println("FORWARD");
}

void move_backward(){
analogWrite(EnA,255);

digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
analogWrite(EnB,255);
digitalWrite(in3,LOW);
digitalWrite(in4,HIGH);
Serial.println("BACKWARD");

void move_left(){
analogWrite(EnA,0);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
analogWrite(EnB,180);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println("LEFT");
}
void move_right(){
analogWrite(EnA,180);
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
analogWrite(EnB,0);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
Serial.println("RIGHT");
}
void stoprobo(){

analogWrite(EnA,0);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
analogWrite(EnB,0);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
Serial.println("STOP");
}

S-ar putea să vă placă și