In SX Microcontrollers, SX/B Compiler and SX-Key Tool, rodneymc wrote: Jon, I'm not understanding why a delay is needed... is this just another way to do it? I thought PULSIN does the waiting, for you... Jim, I think the issue is that you're watching 1 byte instead of 2 bytes for you - if it always comes back as '80' that's one byte, and you need to watch TIM as a word. Jon fixed that for you in his sample code, but I'm surprised it doesn't come up as 2 bytes. Most is 'borrowed' code from the Thereping code, and some older of Jon's Code, but works for me with the SX. Scale CON 10 ' PING))): raw x 10.00 = uS RawToIn CON $0379 ' 1 / 73.746 RawToCm CON $08D1 ' 1 / 29.034 LOW Ping ' make trigger 0-1-0 PULSOUT Ping, Trigger ' activate sensor PULSIN Ping, 1, rawDist ' measure echo pulse rawDist = rawDist * Scale ' convert to uS rawDist = rawDist / 2 ' remove return trip then rawDist can be made into inches or cm inches = rawDist ** RawToIn ' convert to inches cm = rawDist ** RawToCm ' convert to centimeters Note that inches, cm, & rawDist are words. Hope this helps! Rodney ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=188113#m188560 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)