0% found this document useful (0 votes)
73 views34 pages

Practical-1: 1. Arduino Software

The document describes several robotics and automation experiments conducted by a student. It includes details of 5 practical experiments: 1. Studying simulation software for Arduino boards like Arduino and Proteus software. 2. Interfacing a motor driver IC and DC motor to rotate the motor clockwise and anticlockwise using Arduino code. 3. Interfacing a stepper motor using a motor driver IC and Arduino code to rotate the motor clockwise and anticlockwise when a push button is pressed. 4. Interfacing and programming a servo motor to rotate clockwise and anticlockwise using Arduino library functions. 5. Interfacing an ultrasonic sensor and DC motors to move a robot

Uploaded by

Pratik Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views34 pages

Practical-1: 1. Arduino Software

The document describes several robotics and automation experiments conducted by a student. It includes details of 5 practical experiments: 1. Studying simulation software for Arduino boards like Arduino and Proteus software. 2. Interfacing a motor driver IC and DC motor to rotate the motor clockwise and anticlockwise using Arduino code. 3. Interfacing a stepper motor using a motor driver IC and Arduino code to rotate the motor clockwise and anticlockwise when a push button is pressed. 4. Interfacing and programming a servo motor to rotate clockwise and anticlockwise using Arduino library functions. 5. Interfacing an ultrasonic sensor and DC motors to move a robot

Uploaded by

Pratik Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21

Name: Dodiya Keval Enrolment No: 180210111030

Practical-1

Aim: To Study and understand functions of various simulation software for


Arduino Board.
Software: 1. Arduino software

2. Proteus Professional

1. Arduino software
Step-1: Open the Arduino software and select the new project.

Step-2: Write the basic two LEDS on-off program.


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No: 180210111030

Step-3: After verifying the program, copy the “hex” file location of the
program.

2. Proteus Professional

Step-1: Open the proteus professional software and select the new
project.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No: 180210111030

Step-2: Then select the p (p is component) and search the Arduino uno
select and enter.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No: 180210111030

Step-3: Then after search the LEDs then select and enter.

Step-4: Then after connect all the component.


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No: 180210111030

Step-5: Select the Arduino Uno and program file is the location of
Arduino programming ‘hex’ file copy and paste.

Step-6: This project is run and completed.


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Conclusion: In the above experiment, we learnt how to design


microcontroller-based system virtually on proteus.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-2

Aim: Interface motor driver IC and DC motor and write a program to


rotate Motor Clockwise and Anticlockwise also show simulation.
Components: Arduino Uno, L293d Motor Driver and DC Motors.

Connect the components as shown in figure:

Figure-1: Clockwise

Figure-2: Anti-clockwise
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Code:

#define Forw1 12
#define Forw2 10
#define Back1 11
#define Back2 9

void setup()
{
pinMode(Forw1,OUTPUT);
pinMode(Back1,OUTPUT);
pinMode(Forw2,OUTPUT);
pinMode(Back2,OUTPUT);
}

void loop()
{
digitalWrite(Forw1,HIGH);
digitalWrite(Back1,LOW);
digitalWrite(Forw2,HIGH);
digitalWrite(Back2,LOW);
delay(5000);

digitalWrite(Forw1,LOW);
digitalWrite(Back1,HIGH);
digitalWrite(Forw2,LOW);
digitalWrite(Back2,HIGH);
delay(5000);
}

Conclusion: In the above experiment, we interface motor drive IC with


Arduino Uno and rotate the dc motors clockwise and anti-clockwise.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-3

Aim: Interface motor driver IC and Stepper motor and write a program to
rotate Motor Clockwise and Anticlockwise also show simulation
Components: Arduino Uno, L293d Motor Driver IC and Stepper Motor

Circuit diagram is shown in the Figure:

Figure-1: Clockwise

Figure-2: Anti-clockwise
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Working: When we first start the stimulation, the stepper motor initially
rotates clockwise at 150 rpm. When the push button is pressed the motor
start to rotates anti-clockwise at the same speed.

Code:

int i=0;
void setup()
{
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,INPUT);
}
void loop()
{
if(digitalRead(8)==HIGH)
{
i++;
delay(100);
}
if(i%2==0)
{
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,HIGH);

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(50);
}
else
{
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
delay(50);
}
}

Conclusion: In the above experiment, we interface the stepper motor with


Arduino through L293d motor driver IC and run the motor clockwise and anti-
clockwise when push button is pressed.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-4

Aim: Interface Servo motor and write a program to rotate Motor Clockwise
and Anticlockwise also show simulation.
Components: Arduino Uno and Servo motor
Circuit diagram is shown in the figure.

Figure-1: Anti-clockwise

Figure-2: Clockwise
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Working: Servo motor works on the PWM (Pulse Width Modulation)


principle, which means its angle of rotation is controlled by the duration of
pulse applied to its control PIN. Basically, servo motor is made up of
DC motor which is controlled by a variable resistor (potentiometer) and some
gears. Arduino has inbuilt library for servo motor. We only have to write angle
of rotation and it will calculate itself and send data to controller of servo
motor,

Code:

#include<Servo.h>
Servo servo;
void setup()
{
servo.attach(11);
}

void loop()
{
servo.write(0);
delay(1000);
servo.write(180);
delay(1000);
}

Conclusion: In the above experiment, we learnt how servo motor works with
PWM principle and programmed to rotate clockwise and anti-clockwise.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-5

Aim: Interface Ultrasonic Sensor and DC motor and write a program to move
robot forward and reverse direction based on sensor feedback.
Components: Arduino Uno, L293d Motor driver IC, DC motor and Ultrasonic
sensor.

Circuit diagram is shown in the figure:

Figure-1: Forward

Figure-2: Reverse
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Working: Ultrasonic sensors work by emitting sound waves at a frequency
too high for humans to hear. They then wait for the sound to be reflected
back, calculating distance based on the time required. This is similar to how
radar measures the time it takes a radio wave to return after hitting an object.
Initially motors rotate forward. If ultrasonic sensor senses an object less than
100cm close, then the motors rotate reverse for 1 sec.

Code:

int US;
long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT); // Clear the trigger
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
// Sets the trigger pin to HIGH state for 10 microseconds
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in microseconds
return pulseIn(echoPin, HIGH);
}
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
if((US=0.01723*readUltrasonicDistance(8,7)) >= 100)
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
}
else
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
}

Conclusion: In the above experiment, we interface ultrasonic sensor with


Arduino uno board and programmed to rotate motors forward and
reverse based on the input of ultrasonic sensor.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-6

Aim: Interface infrared Sensor and DC motor and write a program to stop
robot if obstacle detected also move robot forward and reverse direction
based on sensor feedback.
Components: Arduino Uno, Infrared sensor, dc motor.

Circuit diagram is shown in the figure:

Figure-1: Forward

Figure-2: Turn Right


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
Working: Initially, motors rotate forward. When Infrared sensor detect any
object then motors stop for 1 sec, rotate reverse for 1 sec and turn left for 1
sec. Then the process repeats if IR sensor still detects any obstacle.

Code:

void setup()
{
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,INPUT);
}
void loop()
{
if(digitalRead(9)==HIGH)
{
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
delay(1000);
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
else
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
delay(100);
}
}

Conclusion: In the above experiment, we interface infrared sensor with


Arduino and dc motors and programmed to detect obstacle and change
direction.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-7

Aim: Simulate manually controlled by 3 Potentiometer 3 DOF (3 Joints)


robotics arm.
Components: Arduino Uno, Servo Motor and Potentiometer.

Circuit diagram is shown in the figure:

Working: Servo Motor has inbuilt library. We only have to give value of
angle. The inputs of potentiometers are divided by 5.6889 which gives the
angle for servo motors in range from 0 to 180 degree.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Code:

#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
void setup()
{
servo1.attach(11);
servo2.attach(10);
servo3.attach(9);
}
void loop()
{
servo1.write((analogRead(A0)/5.68889));
delay(100);
servo2.write((analogRead(A1)/5.68889));
delay(100);
servo3.write((analogRead(A2)/5.68889));
delay(100);
}

Conclusion: In the above experiment, we interface and stimulate servo


motors with potentiometers.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-8

Aim: Simulate Autonomous fix movement of 3 DOF (3 Joints) robotics arm.


Components: Arduino Uno, Infrared sensor and servo motors.
Circuit diagram is shown in the figure:

Figure-1: Initial position

Figure-2: After object is detected


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Working: As shown in the figure, the robotic arm is in the default position.
When the IR sensor detects an object then the arm performs the predefined
action and take the object from the conveyor belt and put it on another place.
Then arm came to default position.

Code:

#include <Servo.h>
Servo base; //Base:
Servo elbow; //Elbow:
Servo actuator; //Actuator:

void setup()
{
base.attach(11);
elbow.attach(10);
actuator.attach(9);
pinMode(8,INPUT); //Infrared Sensor:

//Initially Base is at 90 degree i.e. right side or between object is to be lifted(0 degree)
and placed(180 degree):
//Elbow is vertical i.e. upward at 90 degree:
//Actuator is wide open at 0 degree and closes at 180 degree:

base.write(90);
elbow.write(90);
actuator.write(0);
delay(500);
}

void loop()
{
if(digitalRead(8)==HIGH) //When object is detected at infrared sensor:
{
base.write(0); //Base turns left-side:
delay(1000);
elbow.write(180); //Elbow bends down at 90 degree:
delay(1000);
actuator.write(180); //Actuator holds the object:
delay(1000);
elbow.write(90); //Elbow goes up at 90 degree:
GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
delay(1000);
base.write(180); //Base turns right-side at 180 degree:

delay(1000);
elbow.write(180); //Elbow bends down at 90 degree:
delay(1000);
actuator.write(0); //Actuator opens and release the object:
delay(1000);
elbow.write(90); //Elbow goes up at 90 degree:
delay(1000);
base.write(90); //Base turns left about 90 degree at initial position:
delay(1000);
}
}

Conclusion: In the above experiment, we interface servo motors with


Arduino Uno board and programmed to robotic arm to pick up and place an
object when it is detected on the IR sensor.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-9

Aim: Study and Simulate Forward and inverse kinematics on IITK virtual Lab
Software: IITK Virtual Lab

Introduction: The PUMA 560 is an industrial robot arm with six degrees of freedom
and all rotational joints. In this experiment at first a brief theory about PUMA 560 robot is
presented in the theory section. The theory for mathematical computations was obtained
from a wide variety of sources encompassing books, papers and internet. In simulation
section a virtual model is developed in JavaScript program which is used to investigate
the forward kinematics problem. For more information on other aspects of PUMA 560 and
robotics visitors are advised to follow the references.

Figure-1: PUMA 560

Theory: Programmable Universal Machine for Assembly, more popularly known as


PUMA is an industrial robot arm developed by Victor Scheinman at Unimation, in the year
1978. PUMA comes in various makes viz. PUMA 260, PUMA 560, PUMA 761 etc. Figure
2 shows link-frame assignments in the position corresponding to all joint angles equal to
zero. Here the frame {0} (not shown) is coincident with frame [1} when is zero. Note also
that, for this robot, as for many industrial robots, the joint axes of joints 4, 5, and 6 all
intersect at a common point, and this point of intersection coincides with the origin of
frames {4}, {5}, and {6}. Furthermore, the joint axes 4, 5, and 6 are mutually orthogonal.
This wrist mechanism is illustrated schematically in Fig.4. In this experiment forward
kinematics of PUMA 560 is described through a virtual model. The forward kinematics
problem is concerned with the relationship between the individual joints of the robot
manipulator and the position and orientation of the tool or end effector.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

1. Forward Kinematics:

Forward kinematics (FK) mainly deals with constructing a Denavit-Hartenberg (D-H)


transformation matrix with Puma's parameters obtained from a D-H parameter table
shown below:

Figure 2: Kinematic parameters and frame assignments for the PUMA 560 manipulator.

Figure 3: Kinematic parameters and frame assignments for the forearm of the PUMA 560 manipulator.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Figure 4: Schematic of a 3R wrist in which all three axes intersect at a point and are mutually orthogonal.

Table-1: Puma 560 D-H parameter table


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Transformation matrices of six joints for Puma 560 robot

Kinematics Panel consists of:

ANGLE RANGE DOF

θ1: 320 -160 to +160 Waist Joint

θ2: 270 -225 to +45 Shoulder Joint

θ3: 270 -225 to +45 Elbow Joint

θ4: 280 -110 to +170 Wrist Roll

θ5: 200 -100 to +100 Wrist Bend

θ6: 532 -266 to +266 Wrist Swivel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Simulator:
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

2. Inverse Kinematics:

Given the end-effector position and orientation from Forward kinematics problem, the
inverse kinematics approach is used to obtain the joint angles. But as stated in the
introduction inverse kinematics is more difficult problem than forward kinematics as it
includes much complexity. The relationship between forward and inverse kinematics is
shown in Figure 1. In general, there are two main solution techniques for inverse
kinematics problem one is analytic approach and other is numerical method. Analytic
approach comprises of geometric and algebraic solutions in which joint variables are
solved analytically according to given configuration data.

Figure 1. The schematic representation of forward and inverse kinematics.

Default Ranges of Movements:

ANGLE RANGE DOF

θ1: 320 -160 to 160 Waist Joint

θ2: 270 -225 to 45 Shoulder Joint

θ3: 270 -45 to 225 Elbow Joint

θ4: 280 -110 to 170 Wrist Roll

θ5: 200 -100 to 100 Wrist Bend

θ6: 532 -266 to 266 Wrist Swivel


Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Simulator:

Figure-1: Initial position

Figure-2: Solution 1
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Figure-3: Solution 2

Figure-4: Solution 3
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Figure-5: Solution 4

Conclusion: In the above experiment, we studied and stimulate forward and


inverse kinematics on virtual lab of IIT Kharagpur.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Practical-10

Aim: Simulate Autonomous robot movements using ultrasonic sensor and Infrared
Sensor.
Components: Arduino Uno, L293d motor driver, dc motor, Infrared sensor and
Ultrasonic sensor.

Circuit diagram is shown in the figure.

Figure: Autonomous Robotic Car

Working: Consider the circuit shown in the figure. It is autonomous Arduino


based robotic car with Ultrasonic and Infrared sensor. Ultrasonic sensor is
mounted on servo motor which is mounted on the front of the car. It is used
to detect object on left and right with ultrasonic sensor. Infrared sensor is
fitted on back of the car. It detects the obstacle on the back side. If Ultrasonic
sensor detects an obstacle within 100cm range then servo rotates left and
right and measures the values respectively and then turn the left or right on
the basis of values of ultrasonic sensor which have more clearance.
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030

Code:

#include <Servo.h>
Servo servo_6;
#define IR 9
int US,left,right;

long readUltrasonicDistance(int triggerPin, int echoPin)


{
pinMode(triggerPin, OUTPUT);
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
return pulseIn(echoPin, HIGH);
}

void setup()
{
servo_6.attach(6);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(IR,INPUT);
}
void loop()
{
servo_6.write(90);
delay(500);
while((US=0.01723*readUltrasonicDistance(8,7)) >= 100)
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
}
if(digitalRead(IR)!=HIGH)
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
delay(500);
servo_6.write(180);
delay(500);
left=0.01723*readUltrasonicDistance(8,7);
GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel
Sub Code: 3151110 Sub Name: Robotics and Automation Year: 2020-21
Name: Dodiya Keval Enrolment No:180210111030
delay(1000);
servo_6.write(0);
delay(500);
right=0.01723*readUltrasonicDistance(8,7);
delay(1000);
servo_6.write(90);
delay(1000);
if(left>right)
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
delay(1000);
}
else if(left<right)
{
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(1000);
}
else if(digitalRead(IR)!=HIGH)
{
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(500);
}
left=right=0;
}

Conclusion: In the above experiment, we design and stimulate autonomous


robotic car with ultrasonic sensor and infrared sensor to detect obstacle in
front and back of the car and autonomously turn left or right based on sensor
values.

GEC/BVN/EC/BE/SEM-5/Robotics and Automation/Prof. Pratik Gohel

You might also like