BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – MAINIO
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 283
MAINIO
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
MAINIO
Function
Switch from control of auxiliary I/O pins to main I/O pins (on the BS2p40
only).
Quick Facts
Table 5.58: MAINIO Quick Facts.
BS2p, BS2pe, and BS2px
I/O pin IDs
0 – 15 (just like auxiliary I/O, but after MAINIO command, all references
affect physical pins 5 – 20).
Special Notes
The 24-pin BS2p, BS2pe, and BS2px accept this command, however,
only the BS2p40 gives access to the auxiliary I/O pins.
Related
Commands
AUXIO and IOTERM
Explanation
The BS2p, BS2pe and BS2px are available as 24-pin modules that are pin
compatible with the BS2, BS2e and BS2sx. Also available is a 40-pin
module called the BS2p40, with an additional 16 I/O pins (for a total of
32). The BS2p40's extra, or auxiliary, I/O pins can be accessed in the same
manner as the main I/O pins (by using the IDs 0 to 15) but only after
issuing AUXIO or IOTERM commands. The MAINIO command causes
the BASIC Stamp to affect the main I/O pins (the default) instead of the
auxiliary I/O pins in all further code until the AUXIO or IOTERM
command is reached, or the BASIC Stamp is reset or power-cycled.
The following example illustrates this:
AUXIO ' switch to auxiliary pins
HIGH 0 ' make X0 high
MAINIO ' switch to main pins
LOW 0 ' make P0 low
The first line of the above example will tell the BASIC Stamp to affect the
auxiliary I/O pins in the commands following it. Line 2, sets I/O pin 0 of
the auxiliary I/O pins (physical pin 21) high. Afterward, the MAINIO
command tells the BASIC Stamp that all commands following it should
affect the main I/O pins. The last command, LOW, will set I/O pin 0 of
the main I/O pins (physical pin 5) low.
A SIMPLE MAINIO EXAMPLE.