''''''''''''''''''''''''''''''''''''''''''''
'   SRF05 single pin reading with lcd 03   '
'         example in PicBasic PRO          '
'         by James Henderson 2009          '
''''''''''''''''''''''''''''''''''''''''''''
define OSC 8                                     ' 8Mhz oscillator
define CHAR_PACING 102                           ' 1 stop bit time to make 2 for LCD03

RES con 5                                        ' Constant that is the resolution of the pulsin reading

w0 var word                                      ' Stores the pulse from the srf05

serout PORTC.1,2,[12,4]                          ' Clear lcd screen and hide cursor

loop:
    LOW PORTB.5                                  ' Start with pin low
    Pulsout PORTB.5,5                            ' Pulse out to SRF05
    PULSin PORTB.5,1,w0                          ' Measure pulse from SRF05
    w0 = (w0*5)/58                               ' As we are using an 8Mhz resonator the resolution of the pulse in is 5us therfore we have to multiply by this first to get an acurate reading 
    serout PORTC.1,2,[1,"Range: ",#w0,"  "]      ' Display range
    pause 100
goto loop
