Problems with ir sharp gp2d02
Hi i have an ir sharp sensor a gp2d02 (digital output; range: 4 -80 cm) i tried all the ways to make it work but in vain
in fact; i'm using a pic 16f84 ( using mplab) i'm following exactly what is written on the datasheet in terms of temporisations but it is not working.
it is for a robotics application: i need a led to switch on when the obstacle is at a distance lesser than 40cm.
help me please it's urgent
here is my source code
;*********************************************************************
; gpd202 *
;*********************************************************************
;CK_GP2: clock
;Vout_GP2 : output of gp2
;cgp2 : byte where the datas are kept
GP2D02
movlw D'7'
movwf cT
bcf CK_GP2
call PDelay ; 80ms
bsf CK_GP2
call tempo
bcf CK_GP2
btfsc Vout_GP2
bcf cGp2,0
btfss Vout_GP2
bsf cGp2,0
call tempo
bsf CK_GP2
call tempo
turn
rlf cGp2,f
bcf CK_GP2
btfsc Vout_GP2
bcf cGp2,0
btfss Vout_GP2
bsf cGp2,0
call tempo
bsf CK_GP2
call tempo
decfsz cT,f
goto turn
call tempofin ;1.6ms
return
;*********************************************************************
; PROG. *
;*********************************************************************
start
call tempo
call GP2D02
bcf STATUS,C
movf cGp2,w
sublw D'110'
btfsc STATUS,C
goto notgood ; positive result ==> cGp2 < 110 then none critical distance
goto good ; negative result cgp2 > 110 then dangerous distance
notgood
bcf myled
call temporisation ; just to have time to see if it detected something or not
goto start
good
bsf myled
call temporisation ; just to have time to see if it detected something or not
goto start
END
thx