'sonar example program. dist var word 'sonar distance var. redled con 10 speaker con 9 'sonar pins. init con 4 'change these for different pins. binh con 6 echo con 5 output init 'sonar init. output binh 'sonar binh. output speaker 'speaker output. output redled 'red led. input echo 'echo pin. 'setup for sonar. low init 'init pin. low binh 'binh pin. low speaker 'turn off speaker. low redled 'turn on red led. test gosub sonar 'get sonar reading. debug dec ? dist 'print it to serial port. pause 1000 'pause 1 sec. goto test 'loop back. sonar high init 'hit transducer. pause 1 'pause for ringing. high binh 'raise inhibit. rctime echo,0,dist 'wait for echo. dist=dist/73+9 'dist has number of inches. 'offset for ringing is 9 inches. 'sound travels 1 inch in about 73us. 'rctime increments in 2us increments. pause 40 'give it a rest. low init 'reset sonar stuff. low binh return 'done.