Professional Documents
Culture Documents
dui
noMet
alDet
ect
or
Gr
oupMember
s:
MuhammadRamzanZeshan(
MSCPHY-
E-07)gr
oupl
eader
UmarShahzad(
MSCPHY-
E-18)
MuhammadHami
d(MSCPHY-
E-22)
MuhammadAhmad(
MSCPHY-
E-23)
Super
visedBy
:
Dr
.Haf
izTar
iqMasood
Pr
ojectRepor
tsubmi
tt
edt
otheDepar
tmentofPhy
sics,
Uni
ver
sit
y
ofSahi
wal
Sept
emper2020
Page
1
Acknowl
edgment
Acknowl
edgement
Primari
lyIwouldthanktoALLAH ALMI
GHTYf
ormaki
ngbeabl
eto
compl
etethi
sproj
ectwi
thsuccess.
ThenIwouldl i
ketothankmysuper visorDR.Haf i
zTar i
qMasoodwho
gavemeagol denoppor tunitytodot hiswonder fulpr
oj ectont het opi
cof
Ardui
noMet alDetector,whichalsohel pedmei ndoingal otofresearchandI
camet oknow aboutsomanynew t hings.Iam hi ghl
yindebtedt oDr .Hafiz
Tari
qMasoodf ort heirguidanceandconst antsupervisionaswel lasf or
provi
dingnecessar
yi nfor
mat i
onr egardingthepr oj
ect&al sofortheirsupport
i
ncompl eti
ngtheproject.
ThenIwoul
dl i
ketothankstomyparent
swhohavehelpedmewith
thei
rval
uabl
esuggesti
onsandguidancewhi
chhasbeenhel
pfuli
nvar
ious
phasesoft
hecomplet
ionoft
heproj
ect.
Ican’
tfor
gett
oof f
ermysi ncethankstoourlabassistant
,M.Zeshan
andclassmateswhohelpedmet ocarryoutthisproj
ectsuccessf
ull
yandfor
thei
rvaluabl
eadvi
ceandsuppor
twhi chIhaverecei
vedallt
hetime.
Page
2
Abst
ract
Abst
ract
Page
3
Tabl
eofCont
ent
s
Acknowl
edgement 2
Abst
ract 3
1 Chapt
er1:I
ntr
oduct
ion 5
1.
1 I
ntr
oduct
ion 6
1.
1.1 TheFi
rstMet
alDet
ect
orAppear
: 7
1.
1.2 I
mpr
ovi
ngt
heOr
igi
nal
Met
alDet
ect
orDesi
gn: 7
1.
1.3 The1950st
oPr
esentDayMet
alDet
ect
ors: 8
1.
2 Ty
pesofMet
alDet
ect
or 9
1.
2.1 Ver
yLowFr
equency(
VLF)
: 9
1.
2.2 Pul
seI
ndi
cat
ion(
PI)
: 9
1.
2.3 BeatFr
equencyOsci
l
lat
ion(
BFO)
: 10
2 Chapt
er2:Mat
eri
alsandWor
king 11
2.
1 Mat
eri
alUsed 12
2.
1.1 Requi
redComponent
s 12
2.
1.2 Componentdescr
ipt
ion 12
2.
1.3 Bl
ockDi
agr
am 14
2.
2 Wor
king 15
2.
2.1 Wor
kingConcept
: 15
2.
2.2 Wor
kingExpl
ainat
ion: 17
2.
2.3 Compl
eteAr
dui
noCode: 20
3 Chapt
er3:Adv
ant
agesandDi
sadv
ant
ages 23
3.
1 Adv
ant
ages 24
3.
2 Di
sadv
ant
ages 24
4 Ref
erences 25
Page
4
Chapt
er1:I
ntr
oduct
ion
1 Chapt
er1:I
ntr
oduct
ion
Page
5
Chapt
er1:I
ntr
oduct
ion
1.
1Int
roduct
ion
A met aldetect or
isan electroni
ci nstrument thatdetectst hepr esence
of metal
nearby.Met aldet ectors ar e usef ulf orf indi
ng met ali nclusions
hidden within object s,ormet alobj ects bur i
ed under ground.Theyof ten
consistofahandhel duni twithasensorpr obewhi chcanbesweptov erthe
groundorot herobject s.I fthesensorcomesnearapi eceofmet alt hisis
i
ndicatedbyachangi ngt oneinear phones, oraneedl emov ingonani ndicator.
Usuallythedev icegiv essomei ndicationofdi stance;thecl osert hemet alis,
thehighert het onei nt heear phoneort hehi ghert heneedl egoes.Anot her
commont ypear estat i
onary" wal kthrough"met aldetector
susedf or security
screening
ataccess poi nt
si n pri
sons,
cour t
houses,and airports
to det ect
concealedmet alweaponsonaper son'sbody .Themai nt y
pesofmet al
detectorsarebeat -f
requencyosci l
lati
on,v eryl ow frequency ,pulsei nduction
andindustrial.
Thesi mpl estform ofamet aldet ectorconsi stsofan oscil
l
at or
pr
oduci
ng
an al
ternating current
that passes t hrough a coi l pr oduci
ng an
alt
ernating magneti
cf i
eld.Ifapieceofel ectri
cal
lyconducti
vemet aliscl
ose
tothecoi l,
eddycurr
ents wil
lbei nduced( inducti
vesensor)inthemet al
,and
thi
spr oducesamagnet icfiel
dofi tsown.I fanothercoi
lisusedt omeasure
themagnet icfi
eld(acti
ngasa magnet omet er)
,thechangei nt hemagneti
c
fi
eldduet ot hemetall
icobjectcanbedet ected.
Thef i
rstindustri
almet aldet ectorswer edev el
opedi nthe1960sandwer e
usedext ensivel
yf ormi neralpr ospecti
ngandot herindustr
ialappli
cati
ons.
Usesi ncludedet ecti
ng l
andmi nes,thedet ectionofweaponssuchaskni ves
and guns (
especi ally in
air
por t
security)
, geophysi
cal,
prospecting,
archaeology
and t
reasure hunti
ng.Met al
detectors ar e also used t o det ect for eign bodi es in food,and i n
the constructi
on industry t
o det ect
steelr einforcing bars
in concret
e and
pipesandwi resburiedinwal l
sandf l
oors.
Page
6
Chapt
er1:I
ntr
oduct
ion
1.
1.1TheFi
rstMet
alDet
ect
orAppear
:
Backi nt hemi d1800s,af t
ert heinv entionofel ect ricity ,manysci entists,
scholars,andgol dmi nersbeganexper i
ment i
ngwi t
ht hei deaofdev el
opi nga
machi nethatcoul dl ocatemet alburiedunder ground.Adev icelikethi
swoul d
bei ncredi
blyusef ult ot hemanypr ospect orsst il
llooki ngf orgol daftert he
“GoldRush”and,asar esult
,coul dmaket hef i
rstper sont oper f
ectamet al
detectorvery ,ver yrich.
Thef ir
stmet aldet ect orment ionedi nhistor y,
howev er ,act ual l
yhasnot hingt o
dowi t
hf i
ndi nggol d.I nstead,i twasusedi nanat temptt osav ePresi dent
JamesGar fieldaf t
erhewasshoti nWashi ngt on,D.C.onJul y2,1881,att he
Balti
mor eandPot omacRai l
roadSt at i
onbyChar lesJ. Gui teau.ThePr esi dent
had been shoti nt he back,but ,luckily,t he wound di d notki llhi m.
Unfor t
unatelyt hough, doctorscoul dn’tlocat ethebul letandGar fiel
dcont i
nued
tosuf f
er.
Oneofhi sv isitorsdur i
ngt hatt i
me,Al exanderGr aham Bel l,builtamet al
detectorspeci ficallyt otrytohel pf i
ndt hisbullet,but, sadl y ,hisat t
empt swer e
unsuccessf ul.Itt urnsoutt hemet alspringsi nt hebedPr esidentGar fi
eldwas
l
y i
ngonconf usedt hemachi neandr enderedi tessent iallyusel ess.Pr
esi dent
Garfiel
df i
nallydi edofi nfecti
onf rom hiswoundSept ember19, 1881.
1.
1.2Improv
ingt
heOr
igi
nal
Met
alDet
ect
or
Desi
gn:
Althought hef irstmet aldet ect ordi dn’thelpsav et he20t hPr esidentoft he
UnitedStat es,themachi neAl exanderGr aham Bellmadewasav i
ablemet al
detectorandi twentont obet hepr ototypef orwhichal lothermet aldetectors
from thattimef orwardhav ebeenbased.I niti
all
y,thesemachi neswer er eally
big,compl icated,and r an on v acuum t ubes.But ,theywer e usef uland
continuedt orisei npopul arit
yasar esult.Mosti mpor tantl
yt heseear l
ymet al
detectorswer eusedt of i
ndandcl earl andminesandunexpl odedbombs
acrossEur opeaf t
erWWIandWWI I.
Ataboutt hesamet imeGer har dFi sher, t
hef ounderofFi sherMet alDet ectors,
madeani mpor tantdiscov eryi nhi swor konnav i
gat i
onalsy stems.Ther adio
beamshewasusi ngwer ebei ngdi stortedev eryti
met herewasanor ebear ing
rocki nthear ea.Ashewast r
y i
ngt owor koutt heki nksi nhi ssy st
em,he
reasonedt hatt histypeoft echnol ogyonasmal l
erscal emi ghtbeusef ulasa
met aldetector.I n1925Fi sherwasgr antedt hepat entont hef irstpor t
able
met aldetectorandhesol dhi sf irstFi shermachi net othepubl icin1931.
Page
7
Chapt
er1:I
ntr
oduct
ion
1.
1.3The1950st
oPr esentDayMet
al
Detector
s:
Ev ent houghFi sherwasgr ant edt hef irstpat entonamet aldet ect or ,he’sjust
oneofmanywhor efinedandper fectedt hetechnol ogycur rentlybei ngusedi n
yourmet aldet ector.Anot hermaj orpl ay erinthedev elopmentoft oday ’
smet al
det ectorsi sChar l
es Gar ret t,t he f ounderofGar rettMet alDet ect ors.An
elect ri
cal engineerbyt rade,
Gar rettst artedmet aldet ect ingasahobbyi nt heear ly1960s.Af t
ert ryi
nga
var i
et yoft hemachi nesont hemar kethecoul dn’tf indonet hatwasabl etodo
allhewant ed.Sohebeganwor konhi sownmet aldet ect or .Af termuch
resear chhewasabl et ocr eat eamachi net hatel imi nat edosci llatordr if
t,as
wel lassev eraluni quesear ch coi l
shepat ented al lofwhi ch essent i
ally
rev oluti
oni zedmet aldet ectordesi gnupt othatpoi nt .
Ot herf actorst hathav egreat lyi nf l
uencedt hedev elopmentofmet aldet ectors
asweknow t hem t odayi ncl ude t ransi stors-i nv ented i n 1947 byJohn
Bar deen,Wal t
erBr attain,andWi ll
iam Shockl ey-aswel lasdi scr imi nators,
new sear chcoi ldesigns,andwi relesst echnol ogy .Alloft heset hingsand
mor ehav eal l
owedt hemet aldet ectort obecomet hel ight wei ght ,por table,
easyt ouse, deepseeki ngmachi nesweknowt oday .
Wi tht henumberofpl ay er
si nv olvedbot hprof essional andamat eur ,aswel las
ther apidpaceoft echnol ogi caladv ancementasawhol e,t hef ut ureofmet al
det ectorsi sany one’sguess.Whatcanbeal mostguar anteedt houghi sthat
met aldet ectorswi llcont i
nuet oev olveandchangei nor dert of indev enmor e
treasur e.Tr easur ehunt ersj ustdon’ tqui tand, asy oucanseebyt hehi storyof
themet aldet ect orupt ot hispoi nt,it’st hesepassi onat e,i nv ent iv epeopl e
who’ ve made met aldet ect or st he machi nes t hey ar et oday ;and who’ l
l
cont inuet oi nfl
uencet hef utur eofmet al detect i
ng.
Page
8
Chapt
er1:I
ntr
oduct
ion
1.
2Ty
pesofMet
alDet
ect
or
Metaldetect
ors are devices used to
fi
nd hidden metalli
ci tems.These items r
ange from old coins to gold
nuggetsandmet altri
nkets,andtheyarecommonl yfoundatbeachesand
hist
ori
csi t
es.Allmet aldetector
soperatebysensingchangesi nmagnet i
c
waves caused bymet al.Howev er,some ty
pes are mor e sensi
tive and
expensivethanothers.
1.
2.1Ver
yLowFr
equency(
VLF)
:
Av erylowf r
equency, orVLF,met aldetectorist hemostcommonl yusedt ype
duet oi t
swi der angeofuses.Wi thaVLFdet ect
or,av ari
etyofdi ffer
ent
met al
scanbedet ected.Thistypeofdet ectoroperatesusi
ngt wor oundcoi l
s
ofwi re.Thecoi lont heoutsideist het ransmi t
ter
.Thispar temi t
sal ow-
frequencymagnet i
cf iel
d ontot hegr ound.A met alobjectundert hedi r
t
causest hi
sf i
eldt ober efl
ected.Asepar atei nsi
decoilisthereceiver.This
secondcoi lamplifi
esanymagnet i
creflectionscausesbyahi ddenobj ect.I
f
thesesignalref
lecti
onsar epresent,anaudi ot oneisplay
ed.
Inaddi ti
ont ot hesetwocoils,aVLFmet aldetectorincludesanel ect
ronic
circui
tusedt of i
l
tert
hesignalf rom ther eceiver
.Thi scir
cuitisessenti
all
ya
"tuner"thatallowstheusertoignor ecertainlevel
sofsi gnalandfocusonlyon
thedesi redrange.Becausedifferenttypesofmet alrefl
ectdiff
erentsi
gnals,a
treasurehunt ercan"tuneout"signalsfrom al uminum andst eelandfocuson
valuablessuchasgol dandsi l
ver.
1.
2.2Pul
seI
ndi
cat
ion(
PI)
:
Thepulseinduction,orPI,typeofmet aldet
ectori
samorespeci
ali
zedtype
ofunitmostcommonl yusedbyt reasurehunt
erssear
chi
ngfori
temsdeep
underthesurface.LargeversionsofPIdetect
orsareal
socommonlyusedat
secur
itycheckpointstodetectweapons.
Chapt
er1:I
ntr
oduct
ion
Page
9
APIdet ectorusuall
yusesonl yonecoil
.Aswi thVLFt ypes,acoilsendsouta
magnet i
cf i
eldintothegr ound.Anymet alundergroundr ef
lect
st hissi
gnal.
Insteadofusi ngasepar atecoilfordetecti
on,howev er,aPIuni tquickly
switchesmodest o" l
isten"fort
her ef
lectedsignal.Usingthistimedpul se
met hod,thedev i
cecandi scr
imi
natebetweensi gnalsithassentandst ray
signalsfr
om t hesurroundingarea.ThismakesPIdet ector
smor eaccurate
butalsomor eexpensiv e.
1.
2.3BeatFr
equencyOsci
ll
ati
on(
BFO)
:
A beatfrequencyosci l
lat
ion,orBFO,t ypeofmet aldet ectorist hemost
simpleandi nexpensiv
edesi gn.Fort hisreason,BFO met aldetectorsar e
popularwit
hbegi nner
s.LikeaVLFdet ect
or,t
histypeusest wosepar atewire
coil
sfordetecti
on.Anosci l
latorcreatesaconst antsignalatasetf requency,
whichisemittedbyoneoft hecoils.Thesecondcoi ldetectstheinterference
ofthisfr
equencycausedbymet alobjects,whichresultsi
nachangi ngaudi o
tone.
TheBFOdet ectoroperat
essimil
arl
ytotheVLFmodelbutl
acksthefil
ter
ing
andfine-
tuningabili
tyofthel
att
erdesi
gn.Thi
smakestheBFOdetect
ormor e
pronetomi st
akesandi nter
fer
enceandlessabl
etodiff
erent
iat
ebetween
tr
ashandt reasure.
Page
10
Chapt
er2:Mat
eri
alsandWor
king
2 Chapt
er2:Mat
eri
alsandWor
king
Page
11
Chapt
er2:Mat
eri
alsandWor
king
2.
1Mat
eri
alUsed
Met alDetectorisasecur i
tydev i
cewhi chi susedf ordetect ingmet alswhich
canbehar mf ul
,atv ari
ousplacesl ikeAir port
s,shoppingmal l
s,cinemaset c.
Wear ebui l
dingt he MetalDet ectorusi ngAr duino.Int hispr oj
ect,wear e
goingtouseacoi landcapaci torwhi chwi l
lberesponsibl
ef orthedet ecti
onof
met al
s.Her e wehav e used an Arduino Nano t
o buil
dt his metaldet ect
or
project
.Thi si sveryinterest
ingpr ojectsf orallel
ectr
onicsl overs.Wher ev
er
thi
sdet ectordetectsanymet al nearit,t
hebuzzerst art
sbeepi ngv eryrapi
dly
.
2.
1.1Requi
redComponent
s
1.Arduino(any)
2.Coil
3.10nFcapaci tor
4.Buzzer
5.The1kr esistor
6.330-ohm resist
or
7.LED
8.1N4148di ode
9.BreadboardorPCB
10. Connect i
ngjumperwi
re
11. 9vBat tery
12. Swi tch
2.
1.2Componentdescr
ipt
ion
1.ArduinoUNOR3:TheAr dui
noUnoR3i sami cr
ocontroll
erboardbased
on a r emovable, dual-
inl
i
ne-package ( DI
P) ATmega328 AVR
microcontrol
l
er.Ithas20di gi
talinput/
outputpi
ns( ofwhi ch6canbe
usedasPWM out putsand6canbeusedasanal oginputs).Pr
ograms
canbel oadedont oitf
rom theeasy -
to-
useArduinocomput erprogr
am.
TheAr dui
nohasan
Chapt
er2:Mat
eri
alsandWor
king
Page
12
extensi
vesupportcommunit
y,whi
chmakesi tav
eryeasywayto get
star
tedwor ki
ngwithembeddedel
ect
roni
cs.TheR3i
sthethi
rd,
andl
atest
,
revi
sionoftheArdui
noUno.
2.Coi l
:i
nan el
ectr
icci r
cuit,oneormor etur
ns, usual
lyroughlyci
rcul
aror
cyl
indri
cal
,ofcurr ent-
carryi
ngwi redesignedt opr oducea magneti
c
fi
eld
ortoprovi
de electr
icalresi
stance
orinductance;i
nt helat
tercase,
acoilisal
socall
eda chokecoi l
.
4.Buzzer:A
buzzer
orbeeperi sanaudi
osignal
li
ngdev i
ce,whi
chmaybe
mechanical
,electromechanical
,orpi ezoel
ectr
ic(piezo f
orshort)
.
Typi
calusesof buzzers
andbeepersi
ncludealar
m devi
ces,t
imer
s,and
confi
rmati
onofuseri nputsuchasamousecl i
ckorkeystr
oke.
5.Resistor
:A r
esistor i
sapassivet wo-
ter
minalelect
ri
calcomponentthat
i
mpl ementsel ectr
icalresi
stanceasaci rcui
telement.Inelectr
onic
cir
cuit
s,
resistors
areusedt or educecurr
entflow,adj
ustsi
gnallevels,
todividev olt
ages,bi asactiveelements,andt er
minatetr
ansmission
l
ines,amongot heruses.
6.Diode:A
diode i
sasemiconductordevicet
hatessent
ial
l
yactsasaone
-wayswit
chf orcurr
ent
.Ital
lowscur r
enttofl
oweasil
yinonedirect
ion,
butsever
elyrestr
ict
scur
rentfr
om flowingint
heopposit
edir
ecti
on.
7.LED:A l
ight-
emitt
ingdiode (LED)i sa semiconduct or
li
ghtsource t
hat
emits l i
ght when cur r
ent
flows t hrough i t
. El
ectr
ons i
n t he
semiconduct orr
ecombi newi t
h elect
ronhol es,rel
easingenergyint he
form of
photons.Thecol orofthel i
ght(correspondingtotheener gyof
thephot ons)isdet er
mi nedbyt heener gyr equi
redf orelect
ronst o
crossthe bandgap ofthesemi conductor.
8.Breadboar
d:A br
eadboar
d i
sar ect
angul
arplast
icboar
dwithabunch
oft i
ny hol
es init.These holes l
etyou easil
yinser
telect
roni
c
componentstopr
ototy
pe(meaningtobui
ldandtest
Chapt
er2:Mat
eri
alsandWor
king
Page
13
anearl
yv er
sionof
)anelectr
oniccir
cui
t,li
kethi
sonewi
thabat
ter
y,
swi
tch,
resi
stor
,andanLED(
light
-emit
ti
ngdiode).
9.JumperWi r
e:Jumperwi r
esaresimplywir
esthathaveconnect
orpins
ateachend,al lowingthem tobeusedt oconnecttwopointstoeach
otherwithoutsol der
ing.Jumperwi r
esare ty
pical
l
yused
with
breadboards andotherprot
otypi
ngtoolsi
nor dert
omakei teasy
tochangeaci r
cuitasneeded.
10.
switch:i
nelectronics,anelect
roni
cswi t
chi sanel ectr
oni
ccomponent
ordev i
cethatcanswi tchanelectr
icalci
rcui
t,int
errupt
ingt
hecurrentor
div
er t
ingitfrom oneconduct ortoanot her.Electr
onicswi
tchesar e
consideredbi
nar ydevicesbecausetheycanbeonorcompl et
elyoff.
2.
1.3Bl
ockDi
agr
am
Page
14
Chapt
er2:Mat
eri
alsandWor
king
2.
2Wor
king
2.
2.1Wor
kingConcept
:
L=(
μο *N2 *A)/l
Wher
e,
L-I
nduct
ancei
nHenr
ies
μο-Per
meabi
l
ity
,it
s4π*
10-7f
orAi
r
N-Numberoft
urns
A-I
nnerCor
eAr
ea(
πr2
)i
nm2
l
-Lengt
hoft
heCoi
li
nmet
ers
Whenanymetalcomesneart othecoi
lthencoilchangesit
sinductance.Thi
s
changeini
nductancedependsuponthemet altype.It'
sdecreasesfornon-
magneti
cmetalandincr
easesforf
err
omagneticmat er
ial
sli
keiron.
Page
15
Chapt
er2:Mat
eri
alsandWor
king
Thesei
nductor
sar eusedwhent heneedf orv al
uesoffew micr
oHenr y
.For
val
uesgreat
erthanf ew mil
li
Henrythesear enotasui tabl
eone. I
nbel ow
fi
gureyoucansee aninduct
orwithf
errit
ecor e.TheseFerri
teCoreinductor
hasver
ylar
geinductanceval
ue.
Page
16
Chapt
er2:Mat
eri
alsandWor
king
Sohereinthi
s Ar
dui
no MetalDet
ect
orProj
ect
,wehavet
ofi
ndinductanceof
thecoilt
odetectmetal
s.Sot odothiswehaveusedLRcir
cui
t( Resi
stor
-
I
nductorCi
rcui
t)t
hatwealr
eadymenti
oned.
2.
2.2Wor
kingExpl
ainat
ion:
Wor ki
ngoft his Ardui
noMet alDet ector i
sbittricky.Herewepr ovidetheblock
wav eorpulse,gener at
edbyAr duino,tot heLRhi ghpassf il
ter
.Duet othis,
shortspikeswi llbegenerat
edbyt hecoi linev erytransiti
on.Thepul selength
ofthegener atedspi kesispropor t
ionaltot hei nductanceoft hecoi l
.Sowi th
thehelpoft heseSpi kepulseswecanmeasur ethei nductanceofCoi l.But
hereitisdifficulttomeasur einduct ancepr eciselywi t
ht hatspikesbecause
thatspikesar eofv eryshortdur at
ion( approx.0. 5mi croseconds)andt hatis
verydif
ficul
tt obemeasur edbyAr duino.
Page
17
Chapt
er2:Mat
eri
alsandWor
king
Compl eteArduinocode i
sgivenattheendoft hisArti
cle.Inprogr ammi ng
partofthispr oj
ect
,wehav eusedtwoAr dui
nopins,oneforgener ati
ngblock
wav estobef edinCoilandsecondanal
ogpintoreadcapaci t
orvoltage.Other
thanthesetwopi ns,wehav eusedtwomor eAr
duinopinsf orconnectingLED
andbuzzer .
Page
18
Chapt
er2:Mat
eri
alsandWor
king
2.
2.3Compl
eteAr
dui
noCode:
Code
#def
inecapPinA5
#def
inebuz9
#def
inepulsePi
nA4
#def
inel
ed10
l
ongsumExpect=0;//r
unningsum of64sums
l
ongi
gnor=0;
//numberofignoredsums
l
ongdif
f=0;
//di
ff
erencebetweensum andav
gsum
l
ongpTime=0;
l
ongbuzPeri
od=0;
v
oidsetup()
{
Ser
ial
.begin(9600) ;
pi
nMode( pulsePi n,OUTPUT);
di
git
alWrite(pulsePin,LOW);
pi
nMode( capPi n,INPUT);
pi
nMode( buz, OUTPUT) ;
di
git
alWrite(buz ,
LOW) ;
Page
19
pi
nMode(
led,
OUTPUT)
;
}
v
oi dloop( )
{
i
ntmi nval=1023;
i
ntmaxv al=0;
l
ongunsi gnedi ntsum=0;
for(inti=0; i<256; i
++)
{
//resett hecapaci tor
pinMode( capPi n,OUTPUT) ;
digitalWr i
te( capPi n,LOW) ;
delay Micr oseconds( 20);
pinMode( capPi n,I
NPUT) ;
appl yPulses( )
;
//readt hechar geofcapaci t
or
intval =anal ogRead( capPin);/
/takes13x8=104mi
croseconds
mi nval =mi n(val ,
mi nv al
);
max val=max( v al,
maxv al
);
sum+=v al;
longunsi gnedi ntcTi me=mi l
li
s();
charbuzSt ate=0;
if(cTime<pTi me+10)
Chapt
er2:Mat
eri
alsandWor
king
{
i
f( diff>0)
buzSt ate=1;
elsei f(dif
f<0)
buzSt ate=2;
}
i
f(cTi me>pTi me+buzPer
iod)
{
i
f( diff>0)
buz Stat e=1;
elsei f(diff<0)
buz Stat e=2;
pTime=cTi me;
}
i
f(buzPer i
od>300)
buzSt ate=0;
i
f( buzState==0)
{
digit
alWrite(
led,LOW);
noTone( buz);
}
el
sei f(buzState==1)
{
tone(buz,2000);
digit
alWrite(
led,HIGH)
;
Page
20
}
elseif(buzState==2)
{
tone(buz,500);
digi
talWrite(
led,HIGH)
;
}
}
Chapt
er2:Mat
eri
alsandWor
king
i
gnor=0;
}
i
f(dif
f==0)
buzPeri
od=1000000;
el
se
buzPeri
od=avgsum/(2*
abs(
dif
f))
;
}
v
oidapplyPul
ses( )
{
f
or(i
nti=0;
i<3;i
++)
{
digit
alWri
te(pul
sePin,HIGH)
;//
take3.
5uS
delayMicr
oseconds( 3);
digit
alWri
te(pul
sePin,LOW);
//
take3.
5uS
delayMicr
oseconds( 3);
}
}
Page
21
Chapt
er3:Adv
ant
agesandDi
sadvant
ages
3 Chapt
er3:Advant
agesandDi
sadvant
ages
Page
22
Chapt
er3:Adv
ant
agesandDi
sadvant
ages
3.
1Adv
ant
ages
1.Thi
spr
ojecti
sver
ycheap.
2.Thi
spr
ojecti
seasyt
omake.
3.Wecanf
indl
ostkey
swi
thi
tshel
p.
4.I
tcanal
sohel
psi
nfi
ndi
ngel
ect
ri
cal
wir
ingundert
hewal
l
s.
5.I
thassmal
lsi
zeandi
seasyt
otr
anspor
t.
3.
2Di
sadv
ant
ages
1.Thebiggestadv
ant
ageoft
hispr
ojecti
sthati
thasv
eryl
owmeasur
ing
di
stance.
2.I
tcan’
tfi
ndmet
alobj
ect
sbur
iedundert
hegr
ound.
3.I
tcanal
sogi
vef
alseal
arm whent
hebat
ter
yst
art
edt
odecr
ease.
Page
23
Ref
erences
4 Ref
erences
I
ntr
oduct
ionofMet
alDet
ect
or
Wor
kingofMet
alDet
ect
or
Page
24