PDA

View Full Version : GP2D15 sharp



chip_1
- 13th May 2005, 21:39
How to use GP2D15 sensor?
show my code:

pic 16f84a
picbasic pro

--------------------------------

start:

input portb.1
if portb.1 = 1 then led

led:

high portb.3
pause 1000
low portb.3
pause 1000
goto start
---------------------------------


but not works... possible solution?



THX
by
chip_1

ice
- 14th May 2005, 08:36
chip_1,

Try this..remove the pauses from your program and declare your input and output pins.

--------------------------------
TRISB=%11110111 'make portb.1 and input and portb.3 an output

start:
if portb.1 = 1 then led
else
portb.3=0
goto start

led:
portb.3 =1
goto start
---------------------------------

OR a smaller version would be without the subroutine LED
TRISB=%11110111 'make portb.1 and input and portb.3 an output

start:
if portb.1 = 1 then
portB.3=1
else
portb.3=0
endif
goto start
---------------------------------

chip_1
- 18th May 2005, 07:45
THX ICE ypur code is right!!

chip_1