# POLLRUN Example

Syntax: POLLRUN

NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.

    ' POLLRUN0.BSP
    ' This program demonstrates the POLLRUN command.  It is intended to be
    ' downloaded to program slot 0, and the program called PROGRUN1.BSP
    ' should be downloaded to program slot 1.  I/O pin 0 is set to watch for
    ' a low signal.  Once the Main routine starts running, the program
    ' continuously prints it's program slot number to the screen.  If I/O
    ' pin 0 goes low, the program in program slot 1 (which should be
    ' POLLRUN1.BSP) is run.

    ' {$STAMP BS2p, POLLRUN1.BSP}
    ' {$PBASIC 2.5}

    pgmSlot         VAR     Byte

    Setup:
      POLLIN  0, 0                          ' polled-input, look for 0
      POLLRUN 1                             ' run slot 1 on polled activation
      POLLMODE 3                            ' enable polling

    Main:
      GET 127, pgmSlot
      DEBUG "Running Program #", DEC pgmSlot.LOWNIB, CR
      GOTO Main
      END

    ' POLLRUN1.BSP
    ' This program demonstrates the POLLRUN command.  It is intended to be
    ' downloaded to program slot 1, and the program called PROGRUN0.BSP
    ' should be downloaded to program slot 0.  This program is run when
    ' program 0 detects a low on I/O pin 0 via the polled commands.

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    pgmSlot         VAR     Byte

    Main:
      GET 127, pgmSlot
      DEBUG "Running Program #", DEC pgmSlot.LOWNIB, CR
      GOTO Main
      END

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012