I wrote a snippet of code that:
1. set the 'range' registers, rangeright and rangefront, each to 1
2. gosub blinkloop01 if the 'range' registers are both 1
3. do the pulsout, pulsin exercise
4. gosub blinkloop45 and blinkloop67 if the range registers are 0
I ran the code. The LED's told me that pulsin is loading the range registers with 0. Why??
---------start code-----------
symbol trigright = PORTB.0 ' Define output pin for Trigger pulse
symbol trigfront = PORTB.1 ' Define output pin for Trigger pulse
symbol echoright = PORTB.2 ' Define input pin for Echo pulse
symbol echofront = PORTB.3 ' Define input pin for Echo pulse
rangeright var word
rangefront var word
rangeright = 1
rangefront = 1
if rangeright = 1 and rangefront = 1 then
gosub blinkloop01
endif
main:
DEFINE PULSIN_MAX 65535
pulsout trigright,2
pulsin echoright,1,rangeright
pulsout trigfront,2
pulsin echofront,1,rangefront
pause 10 ' recharge period after ranging completes
'*****test for zeros******
IF rangeright = 0 then
gosub blinkloop45
endif
if rangefront = 0 then
gosub blinkloop67
endif
goto main:
------------end code----------
Bookmarks