sharp GP2D02 IR ranger
Archiver
Posts: 46,084
An enthousiastic message this time! :
Today, I hooked up a sharp GP2D02 IR ranger to my Basic Stamp 2e (approx 20
EUR: www.conrad.nl). I used the acroname
(http://www.acroname.com/robotics/info/examples/GP2D02-4/GP2D02-4.html)
ciruit (using only a standard diode). Took me less then five minutes. It
works great! Great distance resolutions, low noise, no trouble at all. If
anyone is looking for distance measurements (10-120 cm, 2cm res.): try to
get one of these!
happy building!
Matthijs
mod Source (see also at acroname):
'{$STAMP BS2e}
irvar var byte ' GP2D02, value where reading is stored
cl con 14 ' GP2D02, pin 14 is output (clock)
dt con 15 ' GP2D02, pin 15 is the input (data)
piezoard con 13
INPUT dt ' GP2D02, make pin 15 the input
HIGH cl ' GP2D02, make pin 14 output and high
'
' main loop
beep:
for b2 = 0 to 100
pulsout piezoard,300
next
for b2 = 0 to 100
pulsout piezoard,100
next
'-- end of intro tone
again:
GOSUB readGP2D02
DEBUG dec irvar, CR
if irvar>100 then beep
goto again
readGP2D02:
LOW cl ' turn on detector for reading
rl:
IF IN15 = 0 THEN rl ' wait for input high
SHIFTIN dt, cl, MSBPOST, [noparse][[/noparse]irvar]
HIGH cl ' turn detector off
PAUSE 1 ' let detector reset
RETURN
Today, I hooked up a sharp GP2D02 IR ranger to my Basic Stamp 2e (approx 20
EUR: www.conrad.nl). I used the acroname
(http://www.acroname.com/robotics/info/examples/GP2D02-4/GP2D02-4.html)
ciruit (using only a standard diode). Took me less then five minutes. It
works great! Great distance resolutions, low noise, no trouble at all. If
anyone is looking for distance measurements (10-120 cm, 2cm res.): try to
get one of these!
happy building!
Matthijs
mod Source (see also at acroname):
'{$STAMP BS2e}
irvar var byte ' GP2D02, value where reading is stored
cl con 14 ' GP2D02, pin 14 is output (clock)
dt con 15 ' GP2D02, pin 15 is the input (data)
piezoard con 13
INPUT dt ' GP2D02, make pin 15 the input
HIGH cl ' GP2D02, make pin 14 output and high
'
' main loop
beep:
for b2 = 0 to 100
pulsout piezoard,300
next
for b2 = 0 to 100
pulsout piezoard,100
next
'-- end of intro tone
again:
GOSUB readGP2D02
DEBUG dec irvar, CR
if irvar>100 then beep
goto again
readGP2D02:
LOW cl ' turn on detector for reading
rl:
IF IN15 = 0 THEN rl ' wait for input high
SHIFTIN dt, cl, MSBPOST, [noparse][[/noparse]irvar]
HIGH cl ' turn detector off
PAUSE 1 ' let detector reset
RETURN