'*********************************************************** '** ** '** SRF04 Demonstration Software for the BX-24 ** '** ** '** Copyright 2002 - Devantech Ltd ** '** Commercial use of this software is prohibited ** '** Private and educational use only is permitted ** '** ** '** Written by Gerald Coe - January 2002 ** '** ** '*********************************************************** Sub Main() Const EchoPin As Byte = 14 ' Define which pins you want to use here Const InitPin As Byte = 13 Dim Range As Integer Call PutPin(EchoPin, bxInputTristate) Call PutPin(InitPin, bxOutputLow) do Call PulseOut(InitPin, 10, 1) ' 10uS Trigger pulse Range = PulseIn(EchoPin, 1) \ 54 ' use 54 for Cm or 137 for Inches Debug.Print "Range is "; CStr(Range) Call Delay(0.1) loop End Sub