servo with Sharp IR distance as tracking
robban35
Posts: 32
Hi!
i am trying to make a sharp IR distance sensor attached on a servo to track an object...
step 1:
move the servo as a scan from left to right. (this i have managed)
but the following .....
if an object is detected then start track
when an object is detected move the servo to the position were the object is..
i am trying to make a sharp IR distance sensor attached on a servo to track an object...
step 1:
move the servo as a scan from left to right. (this i have managed)
but the following .....
if an object is detected then start track
when an object is detected move the servo to the position were the object is..
Comments
' {$STAMP BS2}
i VAR Word
b VAR word
time VAR Word
go:
FOR i=1 TO 5
PULSOUT 6, 1 ' move the servo
GOSUB dis
IF time<100 THEN en
PAUSE 150
NEXT
st:
FOR i=1 TO 5
PULSOUT 6,1300
IF time<100 THEN en
GOSUB dis
PAUSE 150
NEXT
GOTO go
dis:
HIGH 10
PAUSE 1
RCTIME 10,1,time
DEBUG DEC time,CR
IF time<100 THEN en
RETURN
en:
DEBUG "Target",CR
GOSUB track
RETURN
track:
FOR i=1 TO 1
IF time>500 THEN forward
IF time<500 THEN revers
PULSOUT 6, (b) ' move the servo
GOSUB dis
PAUSE 300
NEXT
RETURN
FORward:
b=B+1
RETURN
revers:
b=B-1
RETURN
If you had one or more stationary sensors in the cam's field of view, you could use that dats to aim your cam.