Shop OBEX P1 Docs P2 Docs Learn Events
Questions on LOOPS — Parallax Forums

Questions on LOOPS

ArchiverArchiver Posts: 46,084
edited 2000-06-11 21:54 in General Discussion
Is pin0 pulled high with a resistor? If not, the pin can assume high
or low states or vary from moment to moment. This could cause your
Stamp to see a low (0) even when the switch is open.

Also, consider the following changes to your code:

WAIT:
IF PIN0 = 1 THEN WAIT
sleep 5
serout 4,n300,("atdt1234567;",13)
sleep 12
serout 4,n300,("atdtb2",13)
sleep 12
serout 4,n300,("ath",13)
sleep 2
TEST:
if pin0=1 THEN WAIT
goto test

Lastly, your second serout instruction sends the literal text "b2"
as opposed to the value held in the variable b2. Is that really your
intent? Maybe ("atdt",#b2,13) would work better.

Steve Parkis

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-06-11 21:18
    The following program waits for a closed contact then calls my pager and
    enters a number (b2). This indicates that switch1 is open. This works fine
    but I do not want the stamp to continue to call the pager while switch1 is
    open. You will see in the program the code/loop TEST where the program
    should go and wait until switch1 is closed again, but this does not work.
    Any suggestions out there? Thanks in advance for your assistance.
    Again, this program works except when switch1 is open it continues to call
    the pager. I want it to "sit" in test until the switch is closed and the
    program resets it self.

    WAIT:
    if pin0=0 then CALL_PAGER
    goto wait

    CALL_PAGER:
    sleep 5
    serout 4,n300,("atdt1234567;",13)
    sleep 12
    serout 4,n300,("atdtb2",13)
    sleep 12
    serout 4,n300,("ath",13)
    sleep 2
    if pin0=0 then test
    goto loop

    TEST:
    if pin0=0 then test
    if pin0=1 then wait
  • ArchiverArchiver Posts: 46,084
    edited 2000-06-11 21:31
    bsy wrote:

    > The following program waits for a closed contact then calls my pager and
    > enters a number (b2). This indicates that switch1 is open. This works fine
    > but I do not want the stamp to continue to call the pager while switch1 is
    > open. You will see in the program the code/loop TEST where the program
    > should go and wait until switch1 is closed again, but this does not work.
    > Any suggestions out there? Thanks in advance for your assistance.
    > Again, this program works except when switch1 is open it continues to call
    > the pager. I want it to "sit" in test until the switch is closed and the
    > program resets it self.
    >
    > WAIT:
    > if pin0=0 then CALL_PAGER
    > goto wait
    >
    > CALL_PAGER:
    > sleep 5
    > serout 4,n300,("atdt1234567;",13)
    > sleep 12
    > serout 4,n300,("atdtb2",13)
    > sleep 12
    > serout 4,n300,("ath",13)
    > sleep 2
    > if pin0=0 then test
    > goto loop
    >
    > TEST:
    > if pin0=0 then test
    > if pin0=1 then wait

    it probably crashes when it hits the "goto loop" command.. (unless LOOP: is
    defined elsewhere in your program!)
    you should change that line to "goto wait"

    also, your last line can be reduced to "goto wait" since there are only two
    options for pin0, the last line will ONLY be executed if pin0=1.

    Jason Lavoie
  • ArchiverArchiver Posts: 46,084
    edited 2000-06-11 21:54
    Try this simple modification:
    WAIT:
    if pin0=0 then CALL_PAGER
    goto wait

    CALL_PAGER:
    sleep 5
    serout 4,n300,("atdt1234567;",13)
    sleep 12
    serout 4,n300,("atdtb2",13)
    sleep 12
    serout 4,n300,("ath",13)
    sleep 2
    'if pin0=0 then test 'should go to test in any condition
    'goto loop 'what loop?
    goto test 'not necessary if the next line is the bellow test:

    TEST:
    if pin0=0 then test 'will only stay here if pin0=0
    if pin0=1 then wait 'instruction here may be goto wait since this line
    'will be executed only if the above conditionis not true.

    ACJacques



    bsy wrote:
    >
    > The following program waits for a closed contact then calls my pager and
    > enters a number (b2). This indicates that switch1 is open. This works fine
    > but I do not want the stamp to continue to call the pager while switch1 is
    > open. You will see in the program the code/loop TEST where the program
    > should go and wait until switch1 is closed again, but this does not work.
    > Any suggestions out there? Thanks in advance for your assistance.
    > Again, this program works except when switch1 is open it continues to call
    > the pager. I want it to "sit" in test until the switch is closed and the
    > program resets it self.
    >
Sign In or Register to comment.