You are on page 1of 32

ARDUINO BASED AUTONOMOUS ROBOT

FOR LOAD, UNLOAD AND TRANSPORTATION APPLICATION

A Project Work submitted for the Fulfilment of the Requirements for the Degree of
BACHELOR OF TECHNOLOGY

ln

ELECTRONICS AND COMMUNICATION ENGINEERING

By

Bipfab Hazarika (Gau -C-L4/OLSI

Rupam Medhi (Ga I-C-L4/O251

Riju Prasad Roy (Gau-C-I4/L-20I].

Under the Supervision and Guidance of

Dr. Agile Mathew

(Assistant Professor, Dept. of ECE)

i'6ar.l l16Iituag (rf 'l'rctnolo4r


Kolnlhr ir Eodol,.sd

"ttfi
r'lartrlr
^at

ralrfrf?irrc

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

CENTRAT INSTITUTE OF TECHNOLOGY, KOKRAJHAR

(A centrally funded institute under Ministry of HRD, Govt. of India)

Website: www.cit.ac.in
reqlerlo)'IlJ

Surraaul8ui uollellunuuof pue slluoJlf,ell JO 'lda6

JosseloJd'lssv

'ro
11",.{*tryr9lltv
lvrlPK,hl
v
"/2."rfl
rosrruadn5

uollel!unuuIoJ pue slluoJpall


'8utleau18u3

u! Atolourllst Jo lolaqleS ,o utnlnluJn) J3$Aulas rllrltla ar.lr


lo, sluauatlnbal 3ql lo ued s 'll-patoid
suolu1n8a'r aql 'rad se paledatd
roJEl/I se peldalle aq o1 sag;lenb pue A3olouqra1lo a$lltsul lerluel lo
ueaqssq>lrornpafoldeql'SIOZAey{olSIOZfuenueJpo;radaqlSu;rnp3]uep!n8pueuols!ru3dns
alnlllsul lErlusf, Jo tulraaultul
}J3l!p Aul repun lno peulel uom salpoquis .reqferloy 'ltolouqral 1o
peser6 nflg pue (SZgltI
uolleclunuruoJ pue stluorlcall 1o lueuryedag eqf of (t6Z-t/tf-r-neg)Aou
-r-neg)lqpaw uednu
,($0/tl-l-neg)elFezEH qeldlg Aq p3ulurqns ,,uo17ot11ddg uolloltodsuw!
palord leqr 4tUel ol sl srr'{I
puo poopn 'poo| to| it.,qoy snowouolnr rE{'oq oulnPw" pelllue 110/6

rlvf lJlrulf

elpul 'utessy 'ovl8 '}LEE9L- reqleJlox


gNtuttNtgNS NO[VftNnwruof oNV s]lNourllll Jo rNlt ruvdlo
(etput *O 'l^og'CUH lo Arlslult l rapun elnl$ul pepun1 {1elrua3 y)

UVHTVu)o),^goloNH]]I Jo SrnI|IsNI lVuINS]

rrrtaa..FJ
l|rr-|.lrr3
etl! a
-tv

Fqap.8 :: l.lfttiox
a],oFnt*I.l(, al-uFl lsltt)
C..ldl ldft ia. Ot Trnroaoat
K.rtt.rl.r :: BodoL.d

I ttaa
t-rttErEa^r-
Ettt!F-'i*ft

CENTRAL INSTITUTE OF TECHNOLOGY,KOKRAJHAR


(A Centrally Funded Institute under Ministry of HRD,Govt. Of India)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Kokrajhar -783370, BTAD, Assam, India

CERTIFICATE

This is to certify that the project work entitled "Arduino bosed Autonomous Robot for Lood, Unlood
and Tronsportotion Applicotion" submitted by Biplab Hazarlka(Gau-c-L4l0L5l, Rupam Medhi(Gau-c-
74/0251 and Riju Prasad Roy(Gau-c-14/L-201) to the Department of Electronics and Communication
Engineering of Central institute of Technology, Kokrajhar, has been prepared as per regulations of
Central Institute of Technology and qualifies to be accepted as Major Project-ll, a part of the
requirements for the eighth semester curriculum of Bachelor of Technology in Electronics and
Communication Engineering.

,V2
r er ifrtlt$
6r
I trl ,\)
\ l.t/''./1-Yt-
\: t t
z-
lO
- r (zy tEK)$
Mr. Rajib Chetia Dr. Sunandan I
Bru!tr rr
EFpt. d.olYil,
Project Coordinator, Head
"r,nELEtF'th'Sl"
Electronics and Communication Engineering Electronics and Communication Engineering

Central Institute of Technology, Kokrajhar Central Institute of Technology, Kokrajhar


c..a6l liditrar (){ .l6hnolo*t
lio|.rilhtr r: Rodoliid

cENTRALINST|TUTEoFTECHNoLoGY,KoKRAJHAR
Of India)
(A Centrally Funded Institute under Ministry of HRD,Govt'

ENGINEERING
DEPARTMENT OF ELECTRONICS AND COMMUNICATION

Kokrajhar - 783370, BTAD, Assam, India

CERTIFICATE

Thisistocertifythattheprojectworkentit|ed,,ArduinobasedAutonomousRobot|orload'
|JntoodondTrunspo|totionApp|icatiot/'submittedbyBip|abHazarika(Gau-c-14/015)'Rupam
Medhi(Gau-c-14/025) and nilu erasaa Roy(Gau-c-14/L-201)
to the Department of Electronics and
per
rechnology, Kokraihar, has been prepared as
communication Engineering of Gentral institute of part of
qualifies to be accepted as Maior Proiect-ll, a
regulations of central Institute of Technologv and
therequirementsfortheeighthsemestercurricu|umofBache|orofTechno|ogyinE|ectronicsand
Communication Engineering.

art)
/,htL
(,.Y/ :
'' (g, o- "u'K
Board of Examiners
nl.\
I lt R

X(ctg
DECLARATION

I hereby declare that the project work entitled "Ardultro based Aubnomous Robot tor Inod'
the guidance
unlood and i,runspoftqtion Appltcotlon" is an authenticated work carried out by us under
curriculum
of Dr. Agile Mathew for the requirements of Major Proiect-ll, as part of the eighth semester
has not been
of Bachelor of Technology in Electronica and Communietion Engineering and this work
submitted for similar purpose anywhere else, except, to the Department of Electronics and
Communication Engineering, Central lnstitute of Technology, Kokraihar'

Npl"L 4lutn'\o-,
Biplab Hazarika
Date: l9-Og-)-olE
Place: Kokrajhar Rolf No: Gau-C-L4 /}Ls
Reg. No: L34694 of 20L4-L5

p.lur^ 62i-h'
Rupam Medhi

Rof f No: Gau-C-l41025

Reg. No: L34702 of 20L4-15

ltf ?Y ^y
Riju Prasad RoY

Rof l No; Gau-C-14 /L-20t

Reg. No: 032862 of 20L5-16


ACKNOWLEDGEMENT

The sotisfoction that occomponies the successful completion of any tosk woutd be incomplete
without the mention of people whose ceoseless cooperotion mode it possible, whose constont guidance
ond encourogement crown all efforts with success.

We bestow our heorted oppreciotion and grotefulness to the elforts mode by our project guide: Asst.
Professor Dh Aglle Mothew, in terms ol the Project tdea, instruction, suggestions and the opportunity
without which our efforts would have remoined ostray.

We do grotefuily acknowledge and express our grotitude to ott rtoIJ members oJ "Electronics and
Communicotion Engineering" ond friends who supported us in preporing project.

Also this prciect work would have been incomplete if Robotics Club oJ Centrot tnstitute of Technology
wos not therc to help us. We are very groteful to Robotics CIub for coopercting with us while making this
project work o success.

Date: I q-Og -Llll

Biplab Hazarika

Roff: Gau-C-14/ltS

Rupam Medhi

Rof l: Gau-C-1.4 /025

Riju Prasad Roy

Roll: Gau-C-14 /L-20L


ABSTRACT

Autonomous robot is one of the most important aspects of Robotics. Our autonomous robot is
actually a line follower robot which is able to follow either a black or white line that is drawn on the
surface consisting of a contrasting colour. lt is designed to move automatically and follow the made plot
line. The oath can be visible like a black line on a white surface or it can be invisible like a magnetic field.
It will move in a particular direction Specified by the user and avoids the obstacle which is coming in the
path. Autonomous Intelligent Robots are robot that can perform desired tasks in unstructured
environments without continuous human guidance. lt is an integrated design from the knowledge of
Mechanical, Electrical, and Computer Engineering. lR sensors based autonomous line follower robot
design and Fabrication procedure which always direct along the black mark on the white surface. The
robot uses several sensors to identify the line thus assisting the bot to stay on the track. The robot is

driven by DC motors to control the movements of the wheels.

The idea of autonomous robot evolved as an alternative for the classical driver based transport
mediums. Classical transport mediums possess many limitations in terms of reliability and cost of
operation. Based on the principles of robotics, line follower robot provides some promising solutions to
various difficult problems in transport systems. These kinds of robots are expected to fulfil the future
needs of transportation to solve various difficult problems in the field of transportation. Such line
follower robots provide greater efficiency than the classical transport mediums for certain very
important applications.

In this project, Arduino based Autonomous Robot for Load, Unload and Transportation
Application; our aim is to design a line follower robot which can transport a small quantity of load to
destination by following black line on a bright surface.

Basically the robot we have made has two main parts. First one is the carrier or the cart and the
second one is the robotic arm. The function of the arm is to take the load from ground and place it on
the carrier. Then the carrier will go to the other end of the line and stops. Then the robotic arm will take
the load from the cart and place it on the ground. After this the robot will go to the starting position and
then the whole process repeats agaih and again.
TABLE OF CONTENTS

L. Introd u ction
1.1 Motivation
t.2 Methodology

2. Hardware Description
2.L Block Diagram
2.2 Circuit Diagram
2.3 Components
i. Arduino UNO'
ii. DC Motor
iii. Motor Driver
iv. Sensor Module
v. Chassis and Wheel
vi. Servo Motor
vii. Robotic Arm

3.'Programming.
3.1 Arduino IDE
3.2 Flow Chart

4. Results & Discussion

5. Conclusion

6. References

7. Appendix

T.LProgram for the project


l.INTRODUCTION

An autonomous line follower robot is basically a robot designed to follow a line or path already
predetermined by the user. This line or path may be as simple as a physical black line on the floor or as
complex path marking schemes e.g. embedded lines, magnetic markers and laser guide markers. ln
order to detect these specific markers or lines, various sensing schemes can be employed. These
schemes may vary from simple low cost line sensing circuit to expansive vision systems. The choice of
these schemes would be dependent upon the sensing accuracy and flexibility required. From the
industrial point of view, line following robot has been implemented in semi to fully autonomous plants.
In this environment, these robots functions as materials carrier to deliver products from one
manufacturing point to another where rail, conveyor and gantry solutions are not possible. Apart from
line following capabilities, these robots should also have the capability to navigate junctions and decide
on which junction to turn and which junction ignore. This would require the robot to have 90 degree
turn and also junction counting capabilities. To add on to the complexity of the problem, sensor
positioning also plays a role in optimizing the robots performance for the tasks mentioned earlier.

Autonomous line follower robots with pick and placement capabilities are commonly used in
manufacturing plants. These move on a specified path to pick the components from specified locations
and place them on desired locations. Basically, a line follower robot is a self-operating robot that detects
and follows a line drawn on the floor. The path to be taken is indicated by either a white line on a black
surface or by a black line on a white surface. The control system used must sense the line and
manoeuvre the robot to stay on course while constantly correcting the wrong moves using feedback
mechanism, thus forming a simple yet effectlve closed-loop system.

l.l Motivation
In daily life we can find that there are many such areas where we a"n araornaa" the process
transportation by using various kinds of robots. We have built the autonomous line follower robot which
can take load from one place and delivers to another place in a very confined area. We have said
confined area because the robot senses a black line on bright surface, this kind of robots can be
implemented outside because of the same region.

1.2 Methodology

This autonomous line follower robot is basically based on infrared sensor technology. The robot
can sense a black line on bright surface and then makes a movement depending on the input value of
the lR sensor. We have used Arduino Uno board to control the robot. In the Arduino Uno board, there is
a program which is used to control the logic of the robot. We have taken lR sensor as input to the
Arduino Uno and based on the reading we make output to the wheels ofthe robot. Also the robotic arm
2. Hardware Description

2.1 Block diagram

Servo
Motor

Power Source Arduino UNO


Servo
Motor 3

Motor Driver

Right Right
Motor 1 Motor 2 Motor Motor 2

Basically in this robot we have used four lR sensors. Two sensors are placed at the front end of the cart
and two sensors are placed at the rear end of the cart, Based on the sensor readings Arduino Uno operate
the motor driver to drive the four DC motors which is used to drive the four wheels.

We have used the port 6,7,8,9 as tNPUTto Arduino Uno board.

And we have used the port 2,3,4,5,IO,L1,12 as OUTpUT from the Arduino Uno board.
t2

2.2 Circuit Diagram

lR Sensors

Motor Driver

DC Motors{Wheels)
al
aa

2.3 Components

i. Arduino UNO

Arduino is an open-source electronics platform based on easy-to-use hardware and software.


Arduino boards are able to read inputs - light on a sensor, a finger on a button, and turn it into an
output - activating a motor, turning on an LED etc. You can tell your board what to do by sending a set
of instructions to the microcontroller on the board. To do so you use the Arduino programming
language (based on Wiring), and the Arduino-Software(lDE)(based on Processing). Arduino Uno is one
type of Arduino board which is being used for this project,

The Arduino platform has become quite popular with people just starting out with electronics, and
for good reason. Unlike most previous programmable circuit boards, the Arduino does not need a
separate piece of hardware (called a programmer) in order to load new code onto the board - we can
simply use a USB cable. Additionally, the Arduino IDE uses a simplified version of C++, making it easier
to learn to program. Finally, Arduino provides a standard form factor that breaks out the functions of
the micro-controller into a more accessible package.
ii. DC Motor
A DC Motor is anv of a class of rotary electrical machines that converts direct current electrical
energy into mechanical energy. The most common types rely on the forces produced by magnetic fields.
Nearly all types of DC motors have some internal mechanism, either electromechanical or electronic, to
periodically change the direction of current flow in part ofthe motor.

DC motors were the first type widety used, since they could be powered from existing direct'current
lighting power distribution systems. A DC motor's speed can be controlled over a wide range, using
either a variable supply voltage or by changing the strength of current in its field windings' Small DC
motors are used in tools, toys, and appliances. The universal motor can operate on direct current but is
a lightweight motor used for portable power tools and appliances. Larger DC motors are used in
propulsion of electric vehicles, elevator and hoists, or in drives for steel rolling mills.
DC Motor Specifications
. Rated voltage:6v DC
o No load current: <280mA
. Operating voltage 1'5-6.5V DC
. produce same amount of
Starting Torque >250g.cm (Force of 250 g acting at a radius of 1cm would
torque as your motor.)
. starting current <5A
. connected to
Rotation Direction CW:[+lterminal connected to the positive power supply,[-]terminal
negative power, clockwise is deemed bythe direction ofthe output shaft
. shaft gap 0.05-0.35mm

iii. Motor Driver


A motor driver is a little current amplifier; the function of motor drivers is to take a low-current
control signal and then turn it into a hiSher-current signalthat can drive a motor'

The 1293D is a quadruple half H-bridge bidirectional motor driver lC that can drive current
of up to
motors, bipolar
6O0mA with voltage range of 4.5 to 35 volts. lt is suitable to drive small DC-geared
stepper motor etc.

Specifications
. Supply voltage range 4.5V to 36V
. 600-mA Output current capability per driver
. Separate Input-logic suPP|Y
. lt can drive small DC-geared motors, bipolar stepper motor.
. Pulsed Current L.2 A Per driver
. Thermal Shutdown
. Internal ESD Protection
o High Noise lmmunity Inputs

Applications
. DC and stepper motor drives
. Position and velocity servomechanisms
iv. Sensor Module
An infrared sensor (lR sensor) is an electronic sensor that measures infrared (lR) light radiating from
objects in its field of view. An infrared sensor is an electronic device, that emits in order to sense some
aspects of the surroundings. An lR sensor can measure the heat of an object as well as detects the motion.
These types of sensors measures only infrared radiation, rather than emitting it that is called as a passive lR
sensor. Usually in the infrared spectrum, all the objects radiate some form of thermal radiations. These
types of radiations are invisible to our eyes, that can be detected by an infrared sensor. The emitter is
simply an lR LED (Light Emitting Diode) and the detector is simply an lR photodiode which is sensitive to lR
light of the same wavelength as that emitted by the lR LED. When lR light falls on the photodiode, the
resistances and these output voltages, change in proportion to the magnitude of the lR light received.

lR Sensor Circuit Diagram and Working Principle


An infrared sensor circuit is one of the basic and popular sensor module in an electronic device. This
sensor is analogous to human's visionary senses, which can be used to detect obstacles and it is one of the
common applications in real time. This circuit comprises of the following components.

a 1M358 lC 2 lR transmitter and receiver pair.


a Resistors of the range of kilo ohms.
a Variable resistors.
o LED(Light Emitting Diode)

+5 Volt

R1 VR2
1 00n

IR R3
Transmitter \ 330n

\\*n*"L, LED
\
\

Ground

L.R.I.E.T

In this project, the transmitter section includes an lR sensor, which transmits continuous lR rays to be
received by an lR receiver module. An lR output terminal of the receiver varies depending upon its
receiving of lR rays. Since this variation cannot be analyzed as such, therefore this output can be fed to a
comparator circuit. Here an operational amplifier (op-amp) of LM 339 is used as comparator circuit.
-
l

When the lR recaiver does not receive a signal, the potential at the inverting input Soes higher than
that non-inverting input of the comparator lC (1M339). Thus the output of the comparator Soes low, but
the LED does not glow. When the lR receiver module receives sitnal to the potential at the inverting
input goes low. Thus the output of the comparator (LM 339) goes high and the LED starts glowinS'
Resistor R1 (1OO ), R2 (10k I and R3 (330) are used to ensure that minimum 10 mA current passes
through the lR LED Devices like Photodiode and normal LEDS respectively. Resistor VR2 (preset=5k ) is
used to adjust the output termtnals. Reslstor vR1 (pr€set=lok l ls used to set the sensltlvlty of the clrcult
Diagram. Read more about lR sensors,

Rerflecterd lR Liglrt

lR liglrt

\A/tritc) 9ur f ace

t-i6irt /\tr*<rr trerd

lR lig,lrt

[}l.lck Srrrf.er-e I
I

I
j

I
I
I
t7

v. Chassis and Wheels


For this project we have used a chassis of wood. The wooden chassis is rigid and durable. We have
attached the wheels on the wooden chassis by glue and nuts and bolts. The wheels are also made of
plastic, but the outer most part of the wheel is made up of soft rubber. The wheels are used to
manoeuvre the robot in every kind of place, whether it is on concrete floor or a terrain area. A sample
picture of the chassis with two wheels is given below.

vi. Servo Motor


A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear
position, velocity and acceleration. lt consists of a suitable motor coupled to a sensor for position feedback.
It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use
with servomotors,

Servomotors are not a specific class of motor although the term servomotor is often used to refer to a
motor suitable for use in a closed-loop control system.

Servomotors are used in applications such as robotics, CNC machinery or automated manufacturing.

We have used three servo motors forthe robotic arm. The first motor is used for the rotating part ofthe
base ofthe arm. Second one is used forthe up and down movement ofthe arm. The third and last servo
motor is used for the gripper part ofthe arm. The gripper is used to hold the load. For our robot we have
used the SG90 model of servo motor,
18

SG90 servo motor SPecifications

Modulation: Analog

Torque: 4.8V: 25.00 oz-in (1.80 kg-cm)

Speed: 4.8V: 0.L2 sec/50"

Weight: 0.32 oz (9.0 g)

Dmensons:
;::;H:r#,
Height:l.14 in (29.0 mm)

Motor Type: 3-pole

Gear Type: Plastic

Rotation/Support: Bushing

Pulse Width: 500-2400 Us


19

vii. Robotic Arm


Thearmportionoftherobotismadeofplastic'Althoughthearmhasvariouspartsbutmain|Yithas
threedistinctmovintparts'Thesethreeseparatemovementsarecausedbythreeseparatemotors.First
motorisattachedwiththebasewhichcanrotateuptogodegreesfromtheinitialposition.Thesecondmotor
motor is attached with
for the up-down movement' The third
is attached with middte part of the robotic arm
thegripperwhichhastwofinSers|ikestructure.Atthetimeofpickupandre|easeofthe|oad,thesetu,o
moves away from each other'
structures either approach each other or

ro I iIlnr

' *- "Wlotor for


Up-Down
ll,r1m MOVement

Motor for
20

3. Programming

3.l Arduino IDE


Arduino integrated development environment (lDE), which is a cross-platform application written in
the programming language Java. A program written with the IDE for Arduino is called a sketch. Sketches
are saved on the development cornputer as text files with the file extension .ino, Arduino Software (lDE)
pre-1.0 saved sketches with the extension .pde.

The Arduino IDE supports the languages C and C++ using special rules of code structuring.

$ sketclr-rnaroga I Arduirro
File Edit Sketch Tools Help
22

4. Results aEd Discusslon

Our project is an innovative idea of intelligent system which has basically line detection feature and will
provide help in various fietds llke Industry sectors, servlce sectors and hospitals. The sensors In this
system are a type of infrared sensor that senses the line and gives the feedback to the microcontroller
unit.

1. The battery activates the circuit.


2. The sensor transmitter transmits the frequency, which reflects from the surface, Sensor receiver
receives the reflected frequenry and gives it to the microcontroller.
3. The microcontroller processes it and gives the signal to motor driver lC.
4. Motor driver lC rotates the motors as per the signal receive and then the wheels rotate.

While testing the robot we have uncovered varlous things. Although the robot can carry approximately
up to lm g but due to the structure of the grlpper of robotic arm lt cannot hold items having larger
area. So we have successfully carried out experiments with smaller load,
23

5. Conclusion

when we implemented the project in real life we have found that the robot is suitable for
small quantity of load. These kinds of robot are useful for many applications,
not only for
transferring a
industrial use but also for domestic use too'

Some advantages of these robots are-

i. Robot movement is automatic.

ii. lt is used for long distance applicatlons.

iii. Simplicity of buildinS,

iv. Fit and forget system and


automations too'
These kinds of automated line follower robots can be used in home and industrial
replacing traditional conveyer
These robots can be used as automated equipment carriers in industries
magnets' These can also
belts. These robots can also be used as automatic cars on roads with embedded
can be used in public
be used at homes for domestic purposes like dusting, floor cleaning etc. These
places like shoppin! malls, museums etc to provlde path guidance'

Robotlcs and
The importance of implementing automation technologies is increasing rapidly'
automation enables Sreat
autonittion will offer great benefits to humanity in the future. Robotics and
largest man-power in the
advantage for people to do works in a short period. since India has second
important supplement that
world, automation is not replacements of the human-power but it is an
caters the need of various operations.
24

5. References

[1]Pakdaman,M.sanaatiyan,M.M.,"Design and lmplementation of Line Follower Robot ", second


pp.585-590'Dec.2mg.
International Conference on Computer and Electrical Engineering TCCEE '09, vol'2,
Technology K' 1' Somaiya College
[2] priyankpatil,,'AvR Line Following Rdbot," Department of Information
of Engineering Mumbai, India. Mar 5, 2010.
with Active Obstacle Avoidance," Acta
[3] t1U Shi-Cai,LlU Guang-]un, "Formation Control of Mobile Robots
Automatlca Sinica, vol. 33, No. 5, 2007.
Control and Obstacle Avoldance for
[4] YANG Tian-Tian; [lU Zhi-Yuan; CHEN Hong; PEI Run, "Formation
Multiple Mobile Robots," Acta Automatica Sinica, Vol. 34 No. 5, 2008'
25

7. Appendix

7.LProgram for the proiect


#include <Servo.h>

Servo myservo;

Servo myservol;

Servo myservo 2; // plnsfor servo

#define mtL2 // rear motcir

#define m12 3

#define m2L 4 l/ frontmotor


#define m22 5

#define sensort 6

7
:

#define sensor2

fdefine sensor3 8

#define sensor4 9

inta=0;
int pos = O; I lfor servo

void setupfl

Serial.beein(9600);

pinMode(sensorl, lN PUT);

pinMode(sensor2, lN PUT);

pinMode(sensor3, lN PUT);

pin Mode(sensor4, lN PUT);

pinMode(m11, OUTPUT);

pinMode (mL2,OUTPUT);

pinMode (m2L, OUTPUT);

pinMo de(m22, OUTPUT);


26

myservo.attach(10);

myservol.attach(11); .

myservo2.attach(12);

void loop0 {

if (a==0)

if(digita I Read (sensort)==11 ;G H &&digital Read (sensor2)== H lG H)

forward0;

else if(digita I Read(sensorl)== H lG H && digital Read(senso12) == LOW)

left0;

else if(digital Read(sensorl)== LOW && d igital Read (sensor2) == H lG H )

rieht0;

else ifid igital Read (sensorl)== LoW && digita I Read(sensor2) == LOW)

{a=1;

Stop0;

llopen
for (pos = 0; pos <= 90i Fos += Ll t llpos = 0; pos <= 180; pos += l goes from 0 degrees to 180 degrees

myservo2.write(pos); l/tell servo to go to position in variable 'pos'

defay(100); ll waits 15ms for the servo to reach the position

//DowN

for (pos = 180; pos )= 90; pos -= 1) | ll eoesfrom 0 degrees to 180 degrees
myservol.write(pos); l/tell servo to go to position in variable 'pos'

defay(Sg); l/ waits 15ms for the servo to reach the position


)

llclose
27

for (pos = 90; pos >= 0; pos -= 1) { // pos = 0; pos <= 180; pos += 1 goes from 0 degrees to 180 degrees

// in steps of 1 degree

miservo2.write(pos); // tell servo to go to posltlon In variable 'pos'

delay(15); l
IIUP

delay(10(X));

for (pos = 90; pos <= 180; pos += 1l { // pos = O; pos <= 180; pos += 1 goes from 0 degrees to 180 degrees

// in steps of 1 degree

myservol.write(pos); // tell servo to go to positlon In variable 'pos'


delay(SO); // waits 15ms for the servo to reach the position

IIROTATE

for(pos=80;pos>=0;pos-=1)lllpos=O;pos<=180'pos+=lgoesfrom0degreestolSOdegrees

// in steps of 1 degree

mysenTo.write(pos); // tell servo to go to position in variable 'pos'

delay(100); // waits 15ms for the servo to reach the position

//DowN
delay(10(X));

for (pos = 180; pos >= 90; pos -= 1) { // goes from O degrees to 180 degrees

// in steps of 1 degree

myservol.write(pos); // tell servo to go to position in variable 'pos'


delay(So); // waits 15ms for the servo to reach the position

/ loPen

for (pos = O; pos <= 90; pos += 1) lll pos=.Oi pos <= 180; pos += l goes from 0 degrees to 180 degrees

// in steps of 1 degree

myservo2.write(pos); // tell servo to 80 to position in variable 'pos'


28

defay(l@); ll walts 15ms for the servo to reach the position \

IIUP

delay(10(X)l;

for (pos = 90; pos <= 180; pos += 1) { // pos = O; pos <= 180; pos += 1 goes from o degrees.to 18o&8rees

// in steps of 1 degree
rpos'
myservol.write(pos); ll tetl servo to go to position in variable

delay(S0); // waits 15ms for the seruo to reach the position

l
//lower most servo go to the above cart position ROTATE

for (pos = 0; pos <=80; pos += 1) { // pos = O; pos <= 180; pos += 1 goes from 0 degrees to 180 degrees

// in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(l(X)); // waits 15ms for the servo to reach the position

else.if(dlgltalRead(5ensorl)==tOW && digitalRead(senso12) == tOW && digitalRead(sensor3)==HIGH &&


digitalRead(sensor4) == 91691

Stop0;

else if (a==1)

if(digltalRead(senso13)==l-Q91 gg6igitalRead(senso14) == [OW)

forwardl0;

else if(dtgltalRead(sensor3)==low && digitalRead(sensor4) == HIGH)

1eft10;

else if(digltalRead(sensor3)==HIGH && digitalRead(s€nsor4) == Low)

rightl0;
29

else if(digitalRead(sensor3)==HlG H && digitalRead(sensor4) == HIGH)

tstop0;

a=0;

//ROTATE

for (pos = ggi pos >= 0; pos -= 1) | ll pos= 0; pos <= 180; pos r= 1 goes from 0 degrees to 180 degrees

//an steps of L degree

myservo.write(pos); lltellservo to go to position in variable 'pos'

defay(100); l/ waits 15ms for the servo to reach the position

//DOwN

delay(1000);

for (pos = 180; pos )= 90; pos -= 1) | /l goesfrom 0 degrees to 180 degrees

/l in steps of l degree

myservol.write(pos); ll tell servo to go to position in variable 'pos'

Oetay(SO); ll waits 15ms for the servo to reach the position

llclose

for (pos = 90; pos >= 0; pos -= 1) { // pos = 0; pos <= 180; pos += 1 goes from o de8rees to 180
degrees

// In steps of 1 degree

myservo2.write(pos); // tell s€rvo to go to posltlon In variable 'pos'

delay(15); l
IIUP

delay(lfiD);

for (pos = 90; pos <= 180; pos += 1) { // pos = 0; pos <= 180; pi5 += 1 goes from 0 degrees to 180
deSrees

// in steps of 1 degree

myservol.wrlte(pos); // tell servo to 8o to position In variable 'pos'


delay(50); // waits 15ms for the servo to reach the position

I ll waits 15ms for the servo to reach the posltion


30

/llower most servo go to the above cart position ROTATE

goes from 0 degrees to 180 degrees


for (pos = 0; pos <=ggj pos += Ll { I / pos = 0; pos <= 180; pos += 1

/l an steps of 1 degree
myservo.write(pos); /l tell servo to go to position in variable 'pos'

def ay(100); // waits 15ms for the servo to reach the position

//DowN

for (pos = 180; Pos >= 90; pos -= 1) { l/ goes from 0 degrees to 180 degrees

l/ in steps of 1 degree

myservo l.write(Pos); // tell servo to go to position in variable 'pos'

delay(50); // waits 15ms for the servo to reach the position

I lopen

ll pos = O; pos <= 180; pos += 1 goes from 0 degrees to 180 degrees
for (pos = 0; pos <= 90; pos += 1) |

// iir steps of 1 degree

myservo2.write(pos); // tell servo to go to position in variable 'pos'

delay(100); // waits 15ms for the servo to reach the position

llvP
delay(1000);

= O; pos <= 180;


pos += 1 goes from 0 degrees to 180 degrees
for (pos = 90; pos <= 180; pos += 1) { // pos

// in steps of 1 degree

myservol.write(pos); // tell servo to go to position in variable 'pos'


delay(SO); // waits 15ms for the servo to reach the position

)
LOW && digitalRead(senso13)==HIGH &&
else if(digitalRead(sensorl)==[Ow && digitalRead(senso12) ==
g1
digitalRead(sensor4) == 1116
31

Stop0;

void riehtfl

digitalWrite(m 11, LOW);

digitalWrite(m12, H lG H);

digitalWrite(m21, LOW);

digitalWrite(m22, LOW);

delay(100);

void leftfl

d igitalWrite(m 11, LOW);

digitalWrite(m 12, LOW);

d igita lWrite(m21, LOW);

digitalWrite(m22, HIG H);

delay(100);

void forwardl0

digitalWrite(m 11, HIGH);

digitalWrite(m 12, LOW);

digitalWrite(m21, H lG H);

digitalWrite(m22, LOW);

void forwardfl

{
digitalWrite(m11, LOW);

digitalWrite(m12, H lG H);

digitalWrite(m21, LOW);

digitalWrite(m22, H lG H);

void 1eft10

digitalWrite(m 11, LOW);

digitalWrite(m12, LOW);

digitalWrite(m21, H lG H);

digitalWrite(m22, LOW);

delay(100);

void rightlfl

{'
digitalWrite(m 11, H lG H);

digitalWrite(m 12, LOW);

digitalWrite(m21, LOW);

digitalWrite(m22, LOW);

delay(100);

void Stop0

digitalWrite(m11, LOW);

digitalWrite(m 12, LOW);

d igitalWrite(m21, LOW);

digitalWrite(m22, LOW);

You might also like