0% found this document useful (0 votes)
23 views23 pages

SMART TURNING MECHANISM1

The document outlines a project for a Smart Turning Mechanism for an Obstacle Avoidance Car, which utilizes an Arduino Uno, ultrasonic sensors, and DC motors to autonomously navigate and avoid obstacles. The car detects its surroundings, makes real-time decisions to change direction or stop, and is designed to enhance safety and efficiency in autonomous driving. It includes detailed descriptions of components, methodology, and embedded code for controlling the robotic car's functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views23 pages

SMART TURNING MECHANISM1

The document outlines a project for a Smart Turning Mechanism for an Obstacle Avoidance Car, which utilizes an Arduino Uno, ultrasonic sensors, and DC motors to autonomously navigate and avoid obstacles. The car detects its surroundings, makes real-time decisions to change direction or stop, and is designed to enhance safety and efficiency in autonomous driving. It includes detailed descriptions of components, methodology, and embedded code for controlling the robotic car's functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

TEAM MEMBERS

1st Sem
ABDULLAH JAFAR (24-ME-73)
HUZAIFA ALI (24-ME-156)
M.IBRAHIM (24-ME-164)
JUNAID FARID (24-ME-152)
WORKSHOP PRACTICAL PROJECT
AITIZAZ ARIF (24-ME-128)
SMART TURNING MECHANIS
M (OBSTACLE AVOIDENCE C
AR)

ABSTRACT:The Smart Turning Mechanism for Obstacle Avoidance Car p


roject is designed to create an autonomous vehicle capable of navigating comp
lex environments by making intelligent decisions to avoid obstacles. Using a co
mbination of advanced sensors and real-time data processing, the car can effec
tively detect obstacles in its path and take immediate action, such as changing
direction or stopping, to prevent collisions.

At the core of this project is the car's ability to scan its surroundings using ultra
sonic sensors, which provide the necessary data to assess potential hazards. U
pon detecting an obstacle, the car can either turn to avoid the object or halt its
movement, depending on the situation. This decision-making process is swift a
nd based on precise measurements, ensuring that the car can respond effectiv
ely to sudden changes in its environment.

The primary objective of this project is to enable the car to navigate autonomo
usly through various terrains and environments without human intervention. It
adapts to real-time changes, continuously assessing the space around it and ad
justing its movement accordingly. This dynamic adaptability is essential for safe
and reliable autonomous driving, especially in environments where obstacles
may appear unexpectedly.

By integrating sensor data with rapid decision-making algorithms, the project d


emonstrates the potential to significantly improve the safety and efficiency of a
utonomous driving systems. The ability to avoid collisions and adjust to environ
mental changes in real-time not only enhances the car's navigational capabiliti
es but also contributes to the development of smarter, more reliable transport
ation systems.

This project represents a step forward in autonomous vehicle technology, offer


ing a foundational solution for future transportation applications. With further
advancements, such as the incorporation of additional sensors, machine learni
ng algorithms for improved decision-making, and enhanced energy manageme
nt, the system can evolve into a more sophisticated and scalable solution. Ulti
mately, the goal is to create smarter, safer autonomous vehicles that can navig
ate diverse environments and pave the way for the next generation of transpor
tation.

METHODOLOGY
COMPONENTS:
ARDUINO UNO: Arduino Uno is a versatile, user-friendly microcontroller boa
rd designed for a wide range of electronic projects. At its heart, it features the
ATmega328P chip, which operates on a 5V power supply, providing enough pr
ocessing power for small to medium-sized applications. Arduino Uno is progra
mmed using the Arduino Integrated Development Environment (IDE), allowing
users to write and upload code with ease.

Its popularity is attributed to its simple design and large supportive community,
which makes it an excellent choice for both beginners and experts. Whether y
ou're building robots, creating smart devices, or experimenting with home aut
omation, the Arduino Uno can handle a variety of tasks, from controlling senso
rs to driving motors.

The board is equipped with a variety of ports to enhance its functionality. It inc
ludes:

 Power Pins: For providing the necessary voltage to power the Arduino
or external components.

 Digital I/O Pins: These pins allow you to interface with devices such as
switches, LEDs, and relays. They can read or send HIGH or LOW signals,
making them essential for simple on/off operations.
 Analog Pins: Used for reading analog sensors like temperature sensors
or potentiometers, providing a range of values instead of just HIGH or LO
W.
 USB Port: For easy programming and power supply, allowing the user t
o connect the board to a computer for code upload and debugging.
 TX/RX Pins: These are used for serial communication with other device
s, such as sensors, modules, or even other microcontrollers.
 Reset Button: A key feature that enables you to restart the program on
the Arduino, useful for troubleshooting or re-running the code without r
e-plugging the board.

In addition to its built-in capabilities, the Arduino Uno benefits from an extensi
ve library of code, tutorials, and shields (add-on boards) that extend its functio
nality. The open-source nature of Arduino also means that there is a vast range
of resources available online, making it easier for users to troubleshoot issues
and share their projects with the global Arduino community.

This combination of simplicity, flexibility, and community support makes the Ar


duino Uno an ideal platform for learning, prototyping, and creating innovative
electronic projects. Whether you are building your first project or scaling up to
more complex systems, the Arduino Uno is a reliable choice for turning your id
eas into reality.

SERVO MOTOR: A servo motor is a small, precise motor designed to rotate t


o a specific angle or position, making it ideal for applications that require contr
olled motion. Unlike standard motors, which continuously spin, servo motors
move within a limited range, typically from 0 to 180 degrees, though some can
rotate up to 360 degrees or more. This precise control is essential in applicatio
ns like robotics, automated systems, camera gimbals, and steering mechanisms.

Servo motors can be easily controlled using an Arduino Uno. With the help of t
he Arduino’s PWM (Pulse Width Modulation) signals, you can easily program t
he motor to move to any angle within its range. The Arduino Uno’s simplicity a
nd the availability of the Servo library make it beginner-friendly, allowing you t
o easily integrate servo motors into projects for tasks like positioning, rotation,
and control. This makes the Arduino Uno and servo motor combination an idea
l choice for both simple and complex motion-control projects.

DC MOTORS: A DC motor (Direct Current motor) is an electric motor that con


verts electrical energy from a DC power source into mechanical energy, produc
ing rotational motion. It operates on the principle that a current-carrying cond
uctor placed within a magnetic field experiences a force. This force generates
motion, which is ideal for many applications requiring controlled rotation.

DC motors are simple, efficient, and widely used due to their ability to run dire
ctly on batteries or DC power sources. They are easy to control, especially in te
rms of speed and direction, by adjusting the voltage or polarity. DC motors are
commonly found in devices like toys, electric vehicles, robotics, and small appli
ances, where reliable, adjustable motion is needed. Their compact size and abil
ity to provide smooth, continuous motion make them versatile for various mec
hanical systems.

 MOTOR DRIVER: A motor driver is an electronic device that controls th


e operation of a motor by regulating the power supplied to it. It acts as a
bridge between the low-power control signals from a microcontroller, lik
e an Arduino, and the high-power requirements of a motor. Since microc
ontrollers cannot directly drive motors due to their limited current outpu
t, the motor driver provides the necessary voltage and current. It also allo
ws control over the motor's speed, direction, and sometimes braking.

 WHEELS: Robotic car wheels are specially designed wheels used in remo
te-controlled cars to provide movement and stability. They are typically
made of rubber for better grip and are attached to motors that allow the
car to move in different directions.

ULTRASONIC SENSOR:An ultrasonic sensor, when paired with an Arduino, i


s a valuable tool for measuring the distance between the sensor and an object
using sound waves. This sensor operates by emitting ultrasonic pulses, which tr
avel through the air until they hit an object, at which point they bounce back to
the sensor. The sensor then calculates the time it took for the sound waves to r
eturn, and from this time, the Arduino can calculate the distance to the object
based on the speed of sound.

The ultrasonic sensor consists of two main components:

1. Transmitter: This part of the sensor emits high-frequency sound waves, t


ypically at 40 kHz. These sound waves are inaudible to the human ear.
2. Receiver: This component listens for the sound waves that have reflecte
d off an object and returned to the sensor.

Working with Arduino:


The process begins when the Arduino sends a trigger signal to the ultrasonic se
nsor, instructing it to emit a sound pulse. The sensor then generates a short pul
se of ultrasonic waves, which propagate through the air. When these waves hit
an object, they reflect back to the sensor's receiver. The sensor measures the ti
me between emitting the pulse and receiving the reflected wave. This time, kn
own as the echo time, is used by the Arduino to calculate the distance to the o
bject using the formula:

Distance=Time×Speed of Sound/2

The division by 2 accounts for the fact that the sound waves travel to the objec
t and back, effectively doubling the distance.

 CHASSIS: It is the frame or structure of a vehicle or robot that h


olds all its components together. It provides support and stabilit
y for motors, wheels, sensors, and other parts.

 BATTERY BOX: A battery box is a container used to hold and o


rganize batteries, providing a secure place to connect and powe
r electronic devices. It often includes connectors and a switch to
control the power supply to the device or circuit.

BATTERIES: A 9V Lithium-Ion battery is a rechargeable power source know


n for its high efficiency and compact design. Unlike traditional 9V alkaline batte
ries, which are single-use, lithium-ion batteries can be recharged hundreds of ti
mes, making them both cost-effective and environmentally friendly. These batt
eries provide a higher energy density, meaning they store more power in a sma
ller size, resulting in better performance and longer runtime for devices.

Lithium-ion technology is also known for its longer lifespan compared to other
rechargeable batteries. They maintain a stable voltage output throughout their
discharge cycle, offering consistent and reliable power. This stability, along wit
h the ability to recharge many times, makes the 9V lithium-ion battery a more
efficient and durable option for powering various devices.
 JUMP WIRES: Jump wires are used to make connections between co
mponents and the Arduino board.These wires are very convenient to use
as they don’t require any soldering,

WORKING
The robotic car utilizes an Arduino Uno as its central controller, which coordin
ates the functions of various components to enable autonomous movement an
d obstacle avoidance. The DC motors provide the power to drive the wheels, a
nd a motor driver regulates their speed and direction, allowing the car to mov
e forward, backward, or turn.

To change the direction of the car, the speed of the diagonal wheels is adjuste
d. This differential drive system allows the car to move in any direction, includi
ng straight, turning left or right, and even rotating in place. The precise control
of motor speed enables smooth and accurate navigation.

For obstacle detection, the car is equipped with an ultrasonic sensor, which e
mits sound waves and measures the time it takes for the waves to reflect back
after hitting an object. The Arduino Uno calculates the distance to obstacles ba
sed on the echo time, allowing the car to avoid collisions. The sensor is mounte
d on a servo motor, enabling it to rotate 90° to both the left and right. This mo
vement allows the car to scan its surroundings and detect obstacles over a wid
er area, making it more aware of its environment.

The chassis provides the structural foundation and supports all the component
s, ensuring everything is securely mounted and aligned for smooth operation. T
he battery box, which houses the 9V lithium-ion batteries, powers the entire s
ystem, providing sufficient energy for the motors, sensors, and the Arduino bo
ard. These batteries are rechargeable, offering long-lasting power and efficienc
y.

Jumper wires are used to connect the various components to the Arduino Uno,
facilitating communication and control. These wires create the electrical conn
ections needed for the motors, sensors, and other devices to function together
in unison.

In operation, the Arduino Uno continuously processes input from the ultrasoni
c sensor, adjusts motor speeds through the motor driver, and uses the servo m
otor to scan for obstacles. The combination of these components enables the c
ar to move autonomously, detect obstacles, and navigate its environment with
increasing accuracy. The integration of these parts results in a fully functional r
obotic car capable of performing tasks such as autonomous navigation, collisio
n avoidance, and responsive movement.

CODE EMBEDDED IN
ARDUINO
#include <AFMotor.h>

#include <NewPing.h>

#include <Servo.h>

#define TRIG_PIN A0

#define ECHO_PIN A1

#define MAX_DISTANCE 200

#define MAX_SPEED 190 // sets speed of DC motors

#define MAX_SPEED_OFFSET 20

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

int in1 = 5;

int in2 = 6;

int in3 = 7;

int in4 = 8;

int ena = 3;

int enb = 11;

Servo myservo;

boolean goesForward=false;

int distance = 100;


int speedSet = 0;

void setup() {

pinMode(in1,OUTPUT);

pinMode(in2,OUTPUT);

pinMode(in3,OUTPUT);

pinMode(in4,OUTPUT);

pinMode(ena,OUTPUT);

pinMode(enb,OUTPUT);

analogWrite(ena,100);

analogWrite(enb,100);

myservo.attach(10);

myservo.write(115);

delay(2000);

distance = readPing();

delay(100);

distance = readPing();

delay(100);

distance = readPing();

delay(100);

distance = readPing();

delay(100);

}
void loop() {

int distanceR = 0;

int distanceL = 0;

delay(40);

if(distance<= 25)

moveStop();

delay(100);

moveBackward();

delay(300);

moveStop();

delay(200);

distanceR = lookRight();

delay(200);

distanceL = lookLeft();

delay(200);

if(distanceR>=distanceL)

turnRight();

delay(250);

moveStop();

}else

{
turnLeft();

delay(250);

moveStop();

}else

moveForward();

distance = readPing();

int lookRight()

myservo.write(50);

delay(500);

int distance = readPing();

delay(100);

myservo.write(115);

return distance;

int lookLeft()

myservo.write(170);
delay(500);

int distance = readPing();

delay(100);

myservo.write(115);

return distance;

delay(100);

int readPing() {

delay(70);

int cm = sonar.ping_cm();

if(cm==0)

cm = 250;

return cm;

void moveStop() {

digitalWrite(in1,LOW);

digitalWrite(in2,LOW);

digitalWrite(in3,LOW);

digitalWrite(in4,LOW);
}

void moveForward() {

digitalWrite(in1,HIGH);

digitalWrite(in2,LOW);

digitalWrite(in3,HIGH);

digitalWrite(in4,LOW);

void moveBackward() {

digitalWrite(in1,LOW);

digitalWrite(in2,HIGH);

digitalWrite(in3,LOW);

digitalWrite(in4,HIGH);

void turnRight() {

digitalWrite(in1,LOW);

digitalWrite(in2,HIGH);

digitalWrite(in3,HIGH);

digitalWrite(in4,LOW);

void turnLeft() {

digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);

digitalWrite(in3,LOW);

digitalWrite(in4,HIGH);

CODE ANALYSIS
The code controls a robotic car using an Arduino. It uses an ultrasonic sensor, s
ervo motor, and DC motors to enable the car to move, avoid obstacles, and na
vigate autonomously. Below is a breakdown of the code structure and its functi
onality:

Libraries Used:
1. AFMotor.h: This library controls DC motors using the Adafruit Motor Shie
ld.
2. NewPing.h: Used for interfacing the ultrasonic sensor, providing function
s for pinging and calculating distance.
3. Servo.h: Manages the servo motor for rotating the ultrasonic sensor to l
ook left and right.

Definitions:
 TRIG_PIN and ECHO_PIN: These define the pins for the ultrasonic senso
r's trigger and echo.
 MAX_DISTANCE: Maximum distance to measure using the ultrasonic sen
sor (in cm).
 MAX_SPEED and MAX_SPEED_OFFSET: These values set the maximum sp
eed of the DC motors and an additional speed adjustment.

Pin Definitions for Motor Control:


 in1, in2, in3, in4: Control pins for the DC motors.
 ena, enb: Enable pins for the motor driver controlling the motors.
 myservo: A servo motor to rotate the ultrasonic sensor.

Global Variables:
 goesForward: A boolean variable to determine the movement direction
(not used actively in the code).
 distance: Stores the distance measured by the ultrasonic sensor.
 speedSet: Controls motor speed (not used in the code).

Setup Function:
In the setup() function:

 The pins for the motors and the servo are initialized as outputs.
 The motor speeds are set using analogWrite on the enable pins (ena and
enb).
 The servo is attached to pin 10, and an initial position of 115° is set (poin
ting forward).
 The program reads the distance from the ultrasonic sensor multiple time
s for initialization, storing the results in distance.

Loop Function:
In the loop() function:

1. The program checks the distance measured by the ultrasonic sensor. If th


e distance is less than or equal to 25 cm (indicating an obstacle is too clo
se), it:

o Stops the robot with moveStop().


o Moves the robot backward for 300 ms using moveBackward().
o Reassesses the situation by looking to the right (lookRight()) and le
ft (lookLeft()).
o Compares the right and left distances. Based on which side has mo
re space, it turns the robot to that side (using turnRight() or turnLe
ft()).

2. If the distance is greater than 25 cm, the robot moves forward using mov
eForward().

The distance is updated after every movement by calling the readPing() functio
n.

Helper Functions:
1.

lookRight():

2.

o Rotates the servo to 50° to check the right side, waits for the dista
nce measurement, then rotates the servo back to 115° (forward) a
nd returns the measured distance.

3.

lookLeft():

4.

o Similar to lookRight(), but the servo is rotated to 170° to check the


left side, waits for the measurement, then returns the distance.

5.

readPing():

6.

o Sends a pulse from the ultrasonic sensor, measures the echo time,
and returns the distance in centimeters.
o If no object is detected (distance 0), it defaults to a maximum valu
e (250 cm) to avoid erroneous readings.

7.

Movement Functions:
8.

o moveStop(): Stops the motors by setting all motor control pins to L


OW.
o moveForward(): Moves the car forward by setting appropriate mot
or pins for forward motion.
o moveBackward(): Moves the car backward by reversing the motor
pin states.
o turnRight(): Makes the car turn right by setting the motor pins acc
ordingly.
o turnLeft(): Makes the car turn left by adjusting the motor pins.

Summary of Behavior:
 The robotic car continuously checks for obstacles in front of it using the u
ltrasonic sensor.
 If an obstacle is detected within 25 cm, the robot stops, moves backward,
and then scans to determine which direction (left or right) has more spa
ce.
 Based on the comparison, the robot turns towards the direction with mo
re space and continues moving forward.
 If there are no obstacles, the robot keeps moving forward.

The code is designed for obstacle-avoidance, allowing the robot to navigate au


tonomously and make decisions based on the environment. The servo motor r
otates the ultrasonic sensor to allow scanning of the surroundings, enabling th
e car to make informed navigation decisions.

PICTURES

or is licensed under CC BY-SA


icensed under CC BY

MOTOR DRIVER ARDUINO UNO SERVO MOTOR


S
under CC BY-SA
licensed under CC BY

Author is licensed under


DC MOTOR ULTRASONIC SENSOR JUMP WIRES

sed under CC BY-NC


BATTERY BOX

PROJECTIONS
CONCLUSION
The Smart Turning Mechanism for Obstacle Avoidance Car project exemplifies
the successful integration of both hardware and software to develop an intellig
ent, autonomous robotic system capable of efficiently navigating various envir
onments. At the heart of this project is the Arduino Uno, acting as the central c
ontroller that coordinates the operation of the system’s various components. T
his includes advanced sensors, such as the ultrasonic sensor, and precise moti
on control via servo motors and DC motors, enabling the car to autonomously
detect obstacles and make real-time decisions to avoid collisions.

By utilizing these cost-effective, readily available components, this project sho


wcases the tremendous potential of DIY and affordable robotics in creating sop
histicated systems. The integration of the ultrasonic sensor allows the car to m
easure the distance between itself and nearby obstacles. This sensor, in combi
nation with the servo motor, facilitates smart turning and maneuvering, enabli
ng the car to make informed navigation decisions based on the environment. T
he DC motors power the movement of the wheels, with a motor driver enablin
g fine-tuned control of speed and direction.

The smart turning mechanism is particularly notable, as it empowers the car to


detect obstacles from multiple angles and choose the best path forward. When
the car encounters an obstacle, it stops, reverses, and then uses a scanning me
chanism, aided by the rotating ultrasonic sensor, to assess available paths. Bas
ed on the distance measurements, the car makes decisions to turn either left o
r right, ensuring efficient navigation through complex spaces. This real-time de
cision-making process is a key feature that mimics behaviors seen in autonomo
us vehicles and provides insights into the fundamental principles of autonomo
us navigation.

This project not only highlights the potential of affordable technology to build s
mart, autonomous systems but also offers a scalable solution applicable to a wi
de range of use cases. The adaptability of the design makes it suitable for a vari
ety of environments, from educational robotics platforms to the development
of more sophisticated autonomous systems in fields such as logistics, robotics,
and even real-world vehicle navigation.
Looking ahead, there are numerous avenues for future enhancements and exp
ansions. One promising direction involves integrating more advanced sensors,
such as infrared sensors or LIDAR systems, to improve the car’s ability to detec
t obstacles and map its surroundings with greater precision. Additionally, imple
menting machine learning algorithms could enhance the decision-making proc
ess, allowing the car to learn from its experiences and optimize its pathfinding
capabilities over time. These algorithms could allow the car to adapt its naviga
tion strategies based on previous encounters, improving both its efficiency and
safety. Furthermore, enhancing the energy management system through the u
se of more efficient power sources or solar cells could extend the car’s operati
onal time, making it more sustainable for prolonged use.

This project serves as an important stepping stone in the broader field of auto
nomous technologies. It provides a solid foundation for exploring advanced co
ncepts in robotics, from the integration of sophisticated sensors to machine lea
rning and autonomous decision-making. The design’s simplicity yet effectivene
ss demonstrates how even basic components, when combined thoughtfully, ca
n lead to impactful innovations. By showcasing the practical potential of smart
navigation systems, this project contributes to the future of autonomous vehic
les, opening doors to safer, smarter, and more efficient transportation solution
s.

In summary, the Smart Turning Mechanism for Obstacle Avoidance Car stands
as a testament to the power of simple, thoughtful design and its potential to dr
ive advancements in autonomous technology. Through its blend of real-time o
bstacle detection, decision-making, and motion control, this project highlights t
he future of smart navigation systems, paving the way for a safer and more int
elligent approach to both robotics and autonomous vehicle development.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy