'*********************************************************** '** ** '** SRF04 Demonstration Software for the Basic Atom ** '** ** '** Copyright 2002 - Devantech Ltd ** '** Commercial use of this software is prohibited ** '** Private and educational use only is permitted ** '** ** '** Written by Gerald Coe - April 2002 ** '** ** '*********************************************************** ' This code must be built with the PROGRAM command - NOT the DEBUG command ' The result is viewed in a terminal window - 9600, No Parity, No Flow Ct, NoEcho ' Click the "Connect" to start it going Trig Con P8 ' Define pin for Trigger pulse Echo Con P9 ' Define pin for Echo pulse Range Var Word ' 16 bit variable for Range Main High Trig ' Produces about 27uS pulse (must be minimum of 10uS) Low Trig Pulsin Echo,1,Range ' measures the range in uS Pause 10 ' SRF04 mandatory 10mS recharge period after ranging completes Range = Range/62 ' use 62 for cm or 149 for inches Serout S_OUT, i9600, ["Range = ", DEC Range, " cm", 13] ' Use terminal window Goto Main ' and around forever End