'------------------------------------------------ 'dirrs.bs2 www.robotics.com ' 'This routine demonstrates how to use the DIRRS 'system from HVW Technologies. 'This is a very useful infra-red range finding 'system. It is similar to the sonar range finder, 'but has several differences. 'It draws less current, easier to interface to, 'and it is cheaper than most sonar units. 'However, it does not detect objects further than '80 cm(~31.5 inches). It is great for short ranges 'and high resolution/accuracy. dist var byte dout con 4 'output to the DIRRS. din con 5 'input from the DIRRS. speaker con 9 'speaker pin. setup: low speaker 'shut off the speaker. high dout 'raise output pin. input din 'set to input pin. main gosub dirrs 'call range finder routine. debug ? dist 'output finding. pause 500 'wait a bit to find again. goto main 'loop back. dirrs: low dout 'lower ouput line. dirrs1: if in5=0 then dirrs1 'loop until pin high. shiftin din,dout,2,[dist\8]'shift in data. high dout return 'done.