{{ ┌──────────────────────────────────────────┐ │ Program Name │ │ Author: Jon Keinath │ │ Copyright (c) 2012 EPSys LLC │ │ www.electronpotential.com │ │ See end of file for terms of use. │ └──────────────────────────────────────────┘ }} CON _clkmode = xtal1 + pll16x ' Crystal and PLL settings. _xinfreq = 5_000_000 ' 5 MHz crystal (5 MHz x 16 = 80 MHz). CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq MS_001 = CLK_FREQ / 1_000 PING_RIGHT = 8 PING_LEFT = 10 PING_CENTER = 9 VAR long range OBJ pst : "Parallax Serial Terminal" ping : "Ping" PUB Main pst.start(115200) pause(1000) repeat range := ping.Inches(PING_LEFT) pst.dec(range) pst.positionX(5) range := ping.Inches(PING_CENTER) pst.dec(range) pst.positionX(10) range := ping.Inches(PING_RIGHT) pst.dec(range) pst.NewLine pause(100) PUB pause(ms) | t t := cnt - 1088 ' sync with system counter repeat (ms #> 0) ' delay must be > 0 waitcnt(t += MS_001) DAT {{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}