Sharp GP2D120 IR Sensor

BeanieBots

Moderator
Have a look at FIG 4 of the datasheet.
It shows the output voltage as a function of distance.

You can use ReadADC to measure the voltage.
Have a read of the command in the manual.
The number you get back is also a fucntion of the power supply voltage so it is important to have a stable supply if you want accurate results.

If things are still not clear after a read of the manual, ask again.
 

slurp

Senior Member
I would usually read the sensor and use the debug command.

It might slow the operation of the program but it's simple to comment out when not required but gives a clear view of variable used by the program.

best regards,
Colin
 

grimmjaw

Member
thanks for the advise.i have using the wizard setup (Analog calibration setup) works perfectly...then i try to write the program myself

main

readadc 0, b1

goto main

but when open debug i cant get any reading..it only say waiting.is my program missing anything?
 

eclectic

Moderator
Please try this.
It works with a 28X1
and a potentiometer.

#picaxe 28X1 ; (or 28X)

main:

readadc 0, b1

debug

goto main


e
 

BeanieBots

Moderator
You have to put a "debug" statement in your code for debug to work.

main:
readadc 0, b1
debug
goto main

The debug window should open automatically when you add the command in as shown above.

EDIT: beaten to it by EC!
 
Top