# IOTERM

(BS2p40)

AUXIO / MAINIO / IOTERM Example

Syntax: IOTERM Port

## Function

Switch program control to main I/O pins or auxiliary I/O pins (on the BS2p40 only) depending on the value of Port.

- Port is a variable/constant/expression (0 - 1) that specifies which I/O port to use.

## Quick Facts

| BS2p, BS2pe, and BS2px
Values for Port | 0 = switch to main I/O group, 1 = switch to auxiliary I/O group.
I/O Pin IDs | 0 - 15 (after IOTERM command, all references affect physical pins 5 - 20 or 21 - 36 depending on state of Port).
Special Notes | Command is accepted by the 24-pin BS2p, BS2pe, and BS2px, but only the 40-pin BS2p40 gives access to the auxiliary I/O pins.
Related Commands | AUXIO, MAINIO

## Explanation

The BS2p, BS2pe, and BS2px is available as a 24-pin module that is pin-compatible with the BS2, BS2e, and BS2sx. Also availabe is a 40-pin module called the BS2p40 with an additional 16 I/O pins (for a total of 32). The BS2p40's I/O pins are organized into two groups, called main and auxiliary. The I/O pins in each group can be accessed in the same manner (by referencing I/O pins 0 - 15) but access is only possible within one group at a time. The IOTERM command causes the BASIC Stamp to affect either the main or auxiliary I/O pins in all further code until the MAINIO, AUXIO or another IOTERM command is reached, or the BASIC Stamp is reset or power-cycled. The value of Port determines which group of I/O pins will be referenced. Using 0 for Port will switch to the main I/O group and using 1 for Port will switch to the auxiliary group.

The following example illustrates this:

      HIGH 0
      IOTERM 1
      LOW 0

The first line of the above example will set I/O pin 0 of the main I/O pins (physical pin 5) high. Afterward, the IOTERM command tells the BASIC Stamp that all commands following it should affect the auxiliary I/O pins (Port = 1). The following LOW command will set I/O pin 0 of the auxiliary I/O pins (physical pin 21) low.

Note that the main I/O and auxiliary I/O pins are independent of each other; the states of the main I/O pins remain unchanged while the program affects the auxiliary I/O pins, and vice versa.

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012