You may right about the stray or false triggering as mentioned in the data sheet.
Now try putting a little delay after the PULSOUT to give the device time to complete the transmit function before listening for an echo.
Code:distance: PULSOUT trig,1 ' each count = 10us PAUSEUS 120 ' Wait for transmit pulse to complete PULSIN sens,1,dist ' will time out in 655ms if nothing received dist= dist/15 'convert to inches PAUSE 100 RETURN END
Bookmarks