Shop OBEX P1 Docs P2 Docs Learn Events
software reset at end of program — Parallax Forums

software reset at end of program

Dirty HowiDirty Howi Posts: 20
edited 2013-12-08 13:01 in BASIC Stamp
or would a loop do better?

i FINALLY have the three button three light thing going (after much consternation) and want to reset the board state after it has ran in anticipation of the next input.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running"

serStr VAR Byte

SERIN 16,84, [DEC serStr]


IF serStr=1  THEN
  HIGH 15
  PAUSE 5000
  LOW 15
ENDIF

IF serStr=2 THEN
  HIGH 14
  PAUSE 5000
  LOW 14
ENDIF

IF serStr=3 THEN
  HIGH 13
  PAUSE 5000
  LOW 13
ENDIF

LOW 22
HIGH 22

or would i wrap this in a loop to go back to the top, or just put a goto label: in it?? been a while since it didnt involve {}; for me so...

Comments

  • SapphireSapphire Posts: 496
    edited 2013-12-08 13:01
    Put DO at the top and LOOP at the end:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DEBUG "Program Running"
    
    serStr VAR Byte
    
    DO
    
      SERIN 16,84, [DEC serStr]
    
      IF serStr=1  THEN
        HIGH 15
        PAUSE 5000
        LOW 15
      ENDIF
    
      IF serStr=2 THEN
        HIGH 14
        PAUSE 5000
        LOW 14
      ENDIF
    
      IF serStr=3 THEN
        HIGH 13
        PAUSE 5000
        LOW 13
      ENDIF
    
    LOOP
    
Sign In or Register to comment.