Final Repoet 2016
Final Repoet 2016
Final Repoet 2016
net/publication/327814718
CITATION
S READS
0 195,671
3 authors, including:
All content following this page was uploaded by Sujeet Kumar Jha on 04 December 2022.
PROJECT REPORT
by:
Sujeet Kumar Jha (32009)
Saurab Dulal (32007)
Manish Kam (32035)
Ahmed Raja Khan (32432)
August 2016
Table of Contents
ABSTRACT.............................................................................................................................i
ACKNOWLEDGEMENT..................................................................................................... ii
ABBREVIATIONS AND SYMBOLS................................................................................iii
LIST OF FIGURES..............................................................................................................iv
LIST OF TABLES.................................................................................................................v
CHAPTER 1...........................................................................................................................1
1. Introduction.......................................................................................................................1
1.1. Background....................................................................................................................1
1.2. Motivation.....................................................................................................................1
1.4. Objectives......................................................................................................................2
1.5. Methodology.................................................................................................................2
1.6. Limitations.....................................................................................................................2
1.7. Organisation of Report.................................................................................................3
1.8. Summary.......................................................................................................................3
CHAPTER 2...........................................................................................................................4
2. Technology and Literature Survey..................................................................................4
2.1. Basic Operation.............................................................................................................4
2.2. Hardware Required.......................................................................................................5
2.3. Software Required.......................................................................................................10
CHAPTER 3.........................................................................................................................11
3. Design and Implementation............................................................................................11
3.1. Schematic.....................................................................................................................11
3.2. Arduino Working Logic.............................................................................................13
3.3. Process Explanation....................................................................................................14
3.4. Programming and Simulation.....................................................................................15
3.5. Summary.....................................................................................................................17
CHAPTER 4.........................................................................................................................18
4. Result and Analysis........................................................................................................18
4.1. Speed Control..............................................................................................................18
4.2. Digital Revolution Counter........................................................................................20
4.4. Summary.....................................................................................................................20
CHAPTER 5.........................................................................................................................21
5. Kinematics of the Robot................................................................................................21
5.1. Mechanical Design.....................................................................................................22
5.2. Cost Estimation...........................................................................................................25
5.3. Summary.....................................................................................................................26
CHAPTER 6.........................................................................................................................27
6. 1. Conclusion.......................................................................................................................27
6.2. Future Work....................................................................................................................27
GANTT CHART....................................................................................................................28
BIBILOGRAPHY...................................................................................................................29
APPENDICES
ABSTRACT
Line Fallowing is one of the most important aspects of robotics. A Line Fallowing Robot
is an autonomous robot which is able to follow either a black line that is drawn on the
surface consisting of a contrasting color. It is designed to move automatically and follow
the line. The robot uses arrays of optical sensors to identify the line, thus assisting the robot
to stay on the track. The array of four sensor makes its movement precise and flexible. The
robot is driven by DC gear motors to control the movement of the wheels. The Arduino
Uno interface is used to perform and implement algorithms to control the speed of the
motors, steering the robot to travel along the line smoothly.This project aims to implement
the algorithm and control the movement of the robot by proper tuning of the control
parameters and thus achieve better performance.In addition the LCD interface is added in
order to display the distance travelled by the robot. It can be used industrial automated
equipment carriers, small household applications, tour guides in museums and other similar
applications, etc.
ACKNOWLEDGEMENT
We wish to express our profound and deep sense of gratitude to Mr. Anand Gacchadar,
Project Co-ordinator,Department of Electrical and Electronics Engineering for sparing his
valuable time to extend help in every step of our project work.
We whole heartedly express our thanks to, Mr. Bikalpa Upadhayaya, Project Supervisor,
Department of Electrical and Electronics Engineering, for sparing time to go through every
tiny detail and give his valuable suggestions to make this project and report a success.
We are mainly indebted to the authors of many references and articles which were used as
the reference.
Last but not the least we would like to thank our friends and family for their help in every
way for the success of this project report.
11
ABBREVIATIONS AND SYMBOLS
A. Abbreviations
Abbreviation Full Form First Used in Page
CPU Central Processing Unit 7
EEPROM Electrically Erasable Programmable Read Only Memory 7
IC Integrated Circuit 11
LCD Liquid Crystal Display
LDR Light Dependent Resistor 4
LED Light Emitting Diode 4
MHz Mega Hertz 7
PWM Pulse Width Modulation 8
Rx Receiver 5
SRAM Static Read Only Memory 7
Tx Transmitter 5
111
LIST OF FIGURES
Figure 2.1: Block Digram of the Line following Robot.........................................................4
Figure 2.2: Arrangements of the Sensor..................................................................................5
Figure 2.3: Schematic of Comparator Logic...........................................................................6
Figure 2.4: Optical Sensor schematic......................................................................................6
Figure 2.5: Arduino Uno Schematic........................................................................................7
Figure 2.6: Pin Configuration IC L293D................................................................................8
Figure 2.7: Low Volt DC Gear Motor attach with Wheel......................................................9
Figure 2.8: Schematic of LCD Panel.......................................................................................9
Figure 2.9: Proxi1nity Sensor.................................................................................................10
Figure 3.1 :Circuit Diagram Of Line following Robot.........................................................12
Figure 3.2: Line Following Process.......................................................................................14
Figure 3.3: Flowchat of the line following Process and Distance Calculation.....................16
Figure 5.1: The Differential steering model..........................................................................21
lV
LIST OF TABLES
Table 1: Arduino Working Logic..........................................................................................13
Table 2: Analysis of effect of PWM on RPM of Motor.......................................................19
Table 3: Comparison between standard Tachometer and Build Tachometer......................20
Table 4: Details of Price of components................................................................................25
Table 5: Gantt Chart...............................................................................................................28
V
CHAPTER!
1. Introduction
Line follower is a machine that can follow a path. The path can be visible like a black
line on a white surface.Sensing a line and maneuvering the robot to stay on course,
while constantly correcting wrong moves using feedback from the sensor forms a
simple yet effective system. It can be used in automobile, industrial automations,
guidance, etc [1].
1.1. Background
1.2. Motivation
How ants always travel in a line, following ani nvisible route in search of food, or back
home. How on roads the lanes is followed to avoid accidents and traffic jams. Ever thought
about a robot which fo1lows line? A perfect or near perfect mimic of nature? After all the
purpose of robotics is to recreate in terms of machines what one see around to solve a
problem or fulfill a requirement.
The area will be benefitted from the project
• Jndustrial automated equipment carriers
• Entertainment and small household applications.
• Tour guides in museums and other similar applications.
• Second wave reconnaissance operations.
1
1.3. Problem Description
In the industry carriers are required to carry products from one manufacturing plant to
another which are usually in different buildings or separate blocks. Conventionally, carts
or trucks were used with human drivers. Unreliability and inefficiency in this part of the
assembly line formed the weakest link. The project is to automate this sector, using carts to
follow a line instead of laying railway tracks which are both costly and an inconvenience.
1.4. Objectives
1.5. Methodology
• After the detail literature survey through the books, periodical, journal, magazine,
websites. The idea of the project is well defined.
• The logic is derived for the intelligence of the robot. It is programmed and burn it
to the Arduino by using the software Arduino® 1.65.
• The accuracy and viability of the program and electronic components is tested in
the simulation software Proteus®.
• After the sucessful simulation result it is implemented in the hardware.
• After the finishing the programming, electrical and electronics part, the
stable,reliable and flexible mechanical design and fabrication is completed.
• Finally system is tested and encountered error is omitted.
1.6. Limitations
2
• The turning radius should be of minimum 100m to take smooth U-tuming of
robot.
• The width of the path must be of 45mm so that it can cover minimum 3 sensors.
• The path should be plane and obstacle free.
• The steering mechanism is not easily implemented in huge vehicles and
impossible for non-electric vehicles.
This report is a documentary delivering the ideas generated, concepts applied, activities
done It contains four chapters. The following is a description of information in this thesis.
Chapter 1 provides a general overview of the project and the use and importance of
autonomous robots in the world. The objectives, scope of project, problem statement are
also described in this chapter.
Chapter 2 describes the hardware development unit in line following robot. This chapter
describes about sensor arrays, Arduino, motor driving system, it also describes the project
methodology and explains hardware development for the design of the robot.
Chapter 3 contains the process explanation with working algorithm, flowchart and sketch
of the Arduino.
Chapter 5 contains all the results obtained from the software experiments that include the
algorithm implemented in a program.
Finally, chapter 5 will summarize the final year project. The conclusion, suggestions or
recommendations for improvements that can be implemented in future are discussed within
this chapter.
1.8. Summary
Line Follower is one of the most important aspects of robotics. A Line Following Robot
is an autonomous robot which is able to follow either a black or white line that is drawn
on the surface consisting of a contrasting color. It is designed to move automatically and
follow the plotted line. It enhances interdisciplinary approach to mechanical,electronic,
electrical and programming skills. The application of the project is range from the
individual domestic appliance to automation and control aspect of large industry.
Human are intelligent natural machine but it has serious limation of efficiency and
realiblity. Robots are made to replace dependency of human force partially. The project
is somehow designed to perform the similar task.
3
CHAPTER2
Motor
- Main Power
Supply
- -
Power
Supply
• '
' -1
;: L293D -1
Proximity
Arduino DC Motor
I Right Motor
I Sensor
r-+
,
Uno -1
.. Control -1
Left Motor
... 'I
I
LM324
Comparator
r
L Threshold
Voltage
, - LCD Sensor
pannel Array
4
2.2. Hardware Required
The hardware required is divided in the following category:
The sensors on the left named as L1, L2 and Rl, R2 on the right side. Assumption should
be considered that when a sensor is on the line it reads O and when it is off the line it reads
1. The Arduino correspondence to the algorithm given below decides the next movement,
trying to position the robot such that all sensors read 0.
With sensors, robots can react and respond to changes in their environment in ways that
appear intelligent or life-like.
5
2.2.2. Comparator
Comparator is a device, which compares two input voltages and gives output high or low.
In circuit diagram it is normally represented by a triangle having-Inverting (negative) Input,
Non-Inverting (positive) Input(+), Vee, Ground, Output.
Properties of comparator:
IfV+ > V- then Vo=Vcc (Digital High Output is 1)
IfV+ < V- then Vo=0 (Digital Low Output is 0)
vccsv
Inverting(-ve)
lnnnt
)mpar tor
Non-Inverting OUTPUT (Vo)
(+ve) Input
GROUND
Figure 2-3: Schemat c of Comparator Logic
R
•---------------------11----c::::=i---,
---------------------f-'
2.2.2.1. Arduino
Arduino is an open-source computer hardware and software company, project and user
community that designs and manufactures microcontroller-based kits for building digital
devices and interactive objects that can sense and control objects in the physical world. The
heart of Arduino is the microcontroller. For Arduino Uno ATmega328 is used.It has
specification of 8 bit CPU, 16 MHZ clock speed, 2 KB SRAM 32 KB flash Memoary, 1 KB
EEPROM [2].
Features:-
• 14 digital input output pins ( 3,5,6,9,10 and 11 pins are able to generate PWM).
;;i-
:!il i
I I I 1-1
DIGITAL (-PWM)
uuU
ANALOG IN <..,
T'"
0
5z
a I
Figure 2-5: Arduino Uno Schematic
1
From Appendix datashcct
7
2.2.3.1 Motor Driver
Motor driver is a current enhancing device; it can also be act as Switching Device. Thus,
after inserting motor driver among the motor and microcontroller. Motor driver taking the
input signals from microcontroller and generate corresponding output for motor.
IC L293D
This is a motor driver IC that can drive two motor simultaneously. Supply voltage (Vss)
is the voltage at which motor drive. Generally, 6V for de motor and 6 to 12V for gear
motor are used, depending upon the rating of the motor. Logical Supply Voltage
deciding what value of input voltage should be considered as high or low .So if the
logical supply voltage equals to +5V, then -0.3V to 1.5V will be considered as Input
low voltage and 2.3V to 5V is taken into consider as Input High Voltage. The Enable 1
and Enable 2 are the input pin for the PWM led speed control for the motor L293D has
2 Channels .One channel is used for one motor.2
ENABLE l Vs.s
Il\i-PUT 1
IN-PUT 4
0 JTP iT 1·
0 JTPUT4
GN"D GND
G:t-.l'"D GND
OUTP JT 2 0 JTPUT 3
Th1P iT 2 JNP1 3
Vs.
ENABLE2
2
Appendix L293D datashcct
8
2.2.3.2. DC Motor
Motor is a device that converts any fonn of energy into mechanical energy or imparts
motion. In constructing a robot, motor usually plays an important role by giving movement
to the robot. In general, motor operating with the effect of conductor with current and the
permanent magnetic field. The conductor with current usually producing magnetic field
that will react with the magnetic field produces by the permanent magnet to make the motor
rotate.There are generally three basic types of motor, DC motor, even servomotor and
stepper motor, which are always being used in building a robot.
DC motors are most easy for controlling. One DC motor has two signals for its
operation. Reversing the polarity of the power supply across it can change the direction
required. Speed can be varied by varying the voltage across motor.
In our project it is used to display the distance travelled by the robot through the output
from the tachometer system.
9
2.2.3.3. Proximity Sensor
The combination of IR- LED and Photodiode is used as the reflective optical sensor. It
generate interrupt when the IR-beam is break to the photodiode. To create the IR break
beam, IR LED is used with a low value resistor so that it shines very bright. The receiver
is Photodiode which biases 'on' whenever the IR LED's light is detected. A sensor will be
placed adjacent the IR link and turned on so as to generate a pulse to the Arduino. The
Arduino LCD interface is used to show the covered distance digitally.
2.4. Summary
The system is completed in to the three divison i.e is the Input system, Processing System
and Output system.
Input system comprises of the optical sensor, is an array of 4 IR-LED and Photodiode pairs
arranged in the fonn straight lines. The output from each sensor is fed into an analog
comparator with the threshold voltage (used to calibrate the intensity level difference of the
line with respect to the surface). These 4 signals(from each photo-reflective sensor) is given
to a priority analog input of the arduino [3].
Processing system is Arduino Uno interface consisting microcontroller Atmega328 which
works on the basic of the logic of the program bum to it.
Output system consist combination L293D and gear-motor The control has 6 modes of
operation, tum left/right, move left/right, and drift left/right. The actual action is caused by
controlling the direction/speed of the two motors (the two back wheels), thus causing a
turn.
CHAPTER3
3.1. Schematic
The schematic of the "Line Following Robot" is shown in the figure. The main component
is the Arduino Uno. Schematic is drawn by using Proteus.
The main features incorporated into the hardware are given below:
• Ardunio Uno.
• The IR-LED with IR illuminance, modified to be reflective sensor.
• The LM324 quad comparator TC.
• A potentiometer to calibrate the reference voltage.
• The H-bridge motor control IC (L293D)
• Motors, with coupled reduction gears.
• Connectors to join the different boards to form one functional device.
• A pair of IR-LED and Photodiode is used as proximity sensor for the designing
techometer
Each of the hardware is dissected and was designed/implemented separately for their
functional and later incorporated as one whole application. This helped in the debugging
processes.
11
..
,,,
I
OUIN. 0 1
. . ----.
Distance (cm),
12
3.2. Arduino Working Logic
Thus totally the microcontroller gets 4 inputs from the sensor circuitry, to the (A3 - AO)
of Arduino to decide what to do when on the line. Below is the complete description
about what each input mean and what needs to be done [4].
13
3.3. Process Explanation
As shown in the data below, is a typical situation involved. At every sampled time the
commands executed by the Arduino is also shown. From the below figure, it should be
clear about the software requirements [5].
0 Sensor
Path
Tum right for the rightmost condition Sharp turn right for the rightmost condition
and turn left for left most condition. and sharp tum left for left most condition.
14
3.4. Programming and Simulation
The program code acts as the decision-maker embedded in the micro-controller deciding
about the outputs for particular set of inputs.The program is coded using Arduino® 1.65.and
is then compiled to form a ".hex" file which can then be burnt into the Arduino.The output
is also checked in simulation using Proteus® [6] .
3.4.1. Flowchart.
The following chart shows implemented logic.
GO STRAIGHT
Left motor = fullspeed
Right motor=
fullspeed
G
leftt motor = slowest
SHARP TURN
RIGHT
Right motor = slowest
Left motor =fullspeed
TURN LEFT
Left motor = slower
Right motor =
fullspeed
15
TURN RIGHT
Left motor = fullspeed
Right motor=slower
MOVE LEFT
Left motor = slow
Right motor
=fullspeed
G- MOVE CIRCULAR
Left Motor=
fullspeed
RightMotor = off
No
Yes
Increase counter by 1.
RETURN
No
-G
Interrupt Occurs
Distance= Distance+2*n*radius of wheel Return to
position where
interrupt occur
Display Distance
Figure 3-3: Flowchat of the line following Process and Distance Calculation
16
3.5. Summary
The logic behind the working of Arduino is to analyse the input from the sensor according
to program fed to it and provide corresponding output to the the motor driver which finally
drive the motor in such way that, it produce required motion.
The differential steering system is implemented to tum the robot. In this system, each back
wheel has a dedicated motor while the front wheels are free to rotate. To move in a straight
line,both the motors are given the same voltage. To manage a tum of different sharpness,
the motor on the side of the tum required is given lesser voltage as level of steering required.
17
CHAPTER4
Mathematical Interpretation:
Rotational power (Pr) is given by:
Pr= Torque (T) X Rotational Speed (ro)
Pr
r=
w
Pr is constant for DC motor for a constant input electrical power. Thus torque (T) is
inverse!y proportional speed (m)
1
r 'Y -
w
18
Calculation:
A= f,ton Vdt
t 0
A = ton 12dt
t 0
A= 12 ton
t
A= 12 X p
Where p is the duty cycle of the PWM control signal; this shows that by varying the duty
cycle of the PWM control,we effectively vary the DC voltage supplied to the motors, thus
controlling their speed. This is generated by the arduino built-in hardware [9].
19
4.2. Digital Revolution Counter
A Digital RPM counter is a measuring instrument which can measure the number of a
rotation machine digitally. The similar concept is used in instrument called
"Tachometer". It is an important measuring device in the field of electrical engineering
& widely used in industries and laboratorial work. IR- Pair is the heart of the system which
found the number of revolution. It works by detecting the black spot in the wheel and
transfer digital high to the arduino.
4.3.1. Calculation
The system is designed in such way that it updates the distance value in every 5 seconds.
i.e. 12 times per minute.
4.4. Summary
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital
means. Digital control is used to create a square wave, a signal switched between on and
off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts)
by changing the portion of the time the signal spends on versus the time that the signal
spends off. The duration of "on time" is called the pulse width. To get varying analog
values, change or modulate that pulse width.
Since, the build techometer can be used, as from the analysis the error percentage within
limit, for the maximum rpm is to be measured i.e 250 rpm.
20
CHAPTERS
,,
b
, ,,,
,,,,,
' SR= (r+b)B
SL= r0
SR= (r + b)0
SM= (r + )0
Where SL and SR give the displacement for the left and right wheels respectively, r is the
turning radius.bis the distance between wheel, and 0 is the angle of tum. SM is the
speed at the center point as the main axle.
21
5.1. Mechanical Design
The chassis of the robot is made up of the acrylic glass since it can carry more load and
have lighter in weight.
The detail orthographic projection of the robot is drawn at the appendix.
Design of Path
The path consists of three U-tums of different radii. Among three, the system swiftly tum
two U-turn and it goes out of track in one initial U-turn and retrace it's path.
22
Picture of Line Following Robot
The picture of the line following robot is captured by the still camera at some angle and
shown below.
23
5.2.1 Turning Radius
The turning radius of a vehicle is the radius of the smallest circular turn (i.e. U-turn)
that the vehicle is capable of making. The term 'turning radius' is a technical term that is
commonly used to mean the full diameter of the smallest circle, but in technical usage
the turning radius still is used to denote the radius.
Calculation:
The total length of the robot car is 172mm (approx 17.2cm.) the minimum turning radius
that it can tum sharply.
The diagram in which robot car is making a tum. The situation is show in the figure above.
The wheels are shown shaded in the figure. The front wheel's center is P and the rear
wheel's center is Q. Let O be the center of the circle, along whose circumference the car
moves. Let L=PQ be the length of the car and let R be the radius of the circle. Sharpest tum
corresponds to smallest possible value of R. Note that PQ is a chord of the circle. Let us
say that the front wheel can rotate at most by an angle w relative to the 'straight' position.
For triangle OPQ [ll].
u+2v=l80° (1)
also , w + v = 90° (2)
From, cosine rule for OPQ:
L2 = R2 + R2 - 2R2 (3)
cos(u)
From eqn (1), (2) and (3)
L
R= Zsinw
At the maximum value of sinw i.e 1 . The turning radius is found to be L/2 = 87.2mm.
Now, the velocity of the automobile is the prime factor to determine the ability to take
tum smoothly or not. So we have to derive the relation between the the turning radius and
the velocity of the robot car.
24
Turning Radius(r) = 100mm.
Acceleration due to gravity(g) = 9.81m/s2 = 9.81xl00 mm/s2
Velocity(v) =?
Coefficient of friction between rubber and cardboard(µ) = 0.07 [11]
v= /µrg
= v 0-.0-7_x_8_-7_5_x_9_8_1_0
= 245.20mm/s = 24.52cm/s
Which is attained at the speed of l.4rps (or, 84 rpm).
25
5.3. Summary
The main criteria of the mechnical design is mainly depends upon the differential steering
mechanism, turning radius. The caculation of turning radius is necessary because it finds
out the mechanical limitation for the types of the curve which is avoded. The turning radius
for the design is found to be 100mm .
So, in case of designing path the maximum turning radius mustn't be less than 100mm.
26
CHAPTER6
6.1. Conclusion
The line following robot is automobile system that has ability to recognize it's path, move
and change the robot's position toward the line in the best way to remain in track.
This project report presents a photodiode sensor based line follower robot design of 200gm
weigh which always directs along the black line on white surface.The electromechenical
robot dimension is l 92x 1OOx 70 mm3 with max rpm 180 at no load and frictionless
condition. The minimum turning radius for the system is 100mm at velocity of 24.2 cm/s.
The robot is able to detect it's path in case it is out of path.
The line following robot project challenged the group to cooperate, communicate, and
expand understanding of electronics, mechanical systems, and their integration with
programming. The successful completion of every task demonstrated the potential of
mechatronic systems and a positive group dynamic.
27
GANTT CHART
Work Accomplished
Work Remaining
28
BIBILOGRAPHY
[l] B. Klaus and P. Hom, Robot Vision. Cambridge, MA: MIT Press, 1986.
[2] J. Warren, J. Adams and H. Molle, "Arduino for Robotics," in Arduino Robotics,
New York, Apress publiction, 2014, pp. 51-83.
[4] Komonya, S. Tachi, K. Tanie, "A Method for Autonomous Locomotion of .Mobile
Robots,"in Journal of Robotics Society of Japan, vol. 2, pp.222-231, 1984.
[5] S. Monk, Programming Arduino Getting Started with Sketches, New Delhi, India: Tata
Macgrawhill, 2012.
[6] Open Source community," Open Source Sketch," January 2015. [Online]. Available:
https://www.arduino.cc/en/Guide/Introduction. [Accessed 25 November 2015].
[7] A. Parsad, "Line Following Robot,"Dept. Elex. & Comm. Eng., Visvesvaraya
Technological University, Banglore, India, 2005
[9] S. Debopath and Md. Jinnah, "Digital RPM meter using Arduino,"Dept. Elect.Eng.,
Ahsanullah Univ. of Sci. & Tech., Dhaka, Bangladesh, 2012.
29
APPENDICES
PROGRAM CODE
Here code is developed in the same view represented by the flowchart. Code accompany
with algorithm side of it.
#include <LiquidCrystal.h>
LiquidCrystal lcd(l2, 11, 7, 5, 4, 3, 6);
float distance;
volatile int count= 0; II volatile is a keyword known as a variable qua/tfier.
int leftlnputl=A2; // Input from the Sensor send to various pin of Arduino from A0-A3.
int leftlnput2=A3;
int rightlnput I=AO;
int rightlnput2=Al;
int leftMotor= 9; II Arduino output PWM to motor for speed control.
int rightMotor= 10;
int leftValuel = 0; // The digital value assigned to the digital read from analog pin from
the Arduino.
int rightValuel = O;
int leftValue2 = O;
int rightValue2 = O;
unsigned long lastmillis = O; // Asigned lastmillis variable to store the current time
value.
void setup()
II put your setup code here, to run once:
{
Serial.begin(9600);
lcd.begin(2, 20); // setup instruction for LCD 2x20.
lcd.setCursor(0,0); //Intialise the position of the cursor for print.
lcd.print("distance (cm)"); II The title print in the LCD displays
30
}
void loop()
II put your main code here, to run repeatedly:
{
leftValue1 = digitalRead (leftlnput1); // digital data from the input sensor is taken
rightValue1= digitalRead (rightlnputl ); // there are all together four sensors two at the
left most and two at the rightmost
leftValue2 = digitalRead (leftlnput2);
rightValue2= digitalRead (rightlnput2);
if(millis() - lastmillis >= 6000) //Uptade every Six seconds
{
detachinterrupt(0)
distance= distance+ 2*3.1416*3*count;
led.setCursor(0,1);
led.print(distance);
count= 0; // Restart the RPM counter
lastmillis = millis(); // Update lastmillis to maintain count difference 6 seconds.
attachinterrupt(0, techno, RISING);
} if
( leftValuel == HIGH && leftValue2 == HIGH && rightValuel == HIGH &&
rightValue2 == HIGH)
{
digitalWrite(leftMotor,LOW); //When all the sensors are out of track it stop for two
sends and begin search for
path for 1sec and again repeat
digitalW rite(rightMotor,LOW);
delay(2000);
digitalWri te(leftMotor,LOW);
digitalWrite(rightMotor,HIGH);
delay(l 000);
}
else
if
( leftValuel == HIGH && leftValue2 == LOW && rightValuel== LOW &&
rightValue2== LOW)
{
31
analogWrite (leftMotor, 191); //The left motor moves with slightly slow speed while
right motor moves with slower speed
analogWrite (rightMotor,185); //The robot moves turns toward the right
//delay(l000);
}
else
if( leftValuel == HIGH && leftValue2 == HIGH && rightValuel== LOW &&
rightValue2== LOW)
{
analogWrite (leftMotor,191 ); //The left motor moves with slightly slow speed while
right motor moves with slower speed
analogWrite (rightMotor, 64); //The robot moves turns toward the right
// delay(l000);
}
else
if( leftValuel == HIGH && leftValue2 == HIGH && rightValuel== HIGH &&
rightValue2== LOW)
{
analogWrite (leftMotor,255 ); //The left motor moves with slightly slow speed while
right motor moves with slower speed
analogWrite (rightMotor,64); //The robot moves turns toward the right
//delay(I000);
}
Else
if ( leftValuel == LOW && leftValue2 == LOW && rightValuel== LOW &&
rightValue2== HIGH)
{
analogWrite (leftMotor, 127); //The left motor moves with slightly slow speed
while right motor moves with slower speed
analogWrite (rightMotor,191);
// delay(1000);
}
else
if( leftValuel == LOW && leftValue2 == LOW && rightValuel== HIGH &&
rightValue2== HIGH)
{
32
analogWrite (leftMotor, 64); //The left motor moves with slightly slow speed
while right motor moves with slower speed
analogWrite (rightMotor,191);
// delay(1000);
}
else
if( leftValuel == LOW && leftValue2 == HIGH && rightValuel== HIGH &&
rightValue2== HIGH)
{
analogWrite (leftMotor,64); //The left motor moves with slightly slow speed
while right motor moves with slower speed
analogWrite (rightMotor,255);
// delay(l000);
}
else if ( leftValue I== LOW && leftValue2 == LOW && rightValuel== LOW &&
rightValue2== LOW)
{
analogWrite (rightMotor,255); // The robot moves with full speed when all of the
sensor is low.
analogWrite (leftMotor,255 );
} }
void techno()
{
count++; }
33