BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – XOUT
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 467
Table 5.125 lists the XOUT command codes and their functions:
Table 5.125: XOUT Commands
and Their Function.
Command Value Function
UNITON %10010 Turn on the currently selected unit.
UNITOFF %11010 Turn off the currently selected unit.
UNITSONf %11100 Turn off all modules in this house code.
LIGHTSON %10100 Turn on all lamp modules in this house code.
DIM %11110 Reduce brightness of currently selected lamp.
BRIGHT %10110 Increase brightness of currently selected lamp.
Note: In most applications, it’s not necessary to know the code for a given X-10 instruction.
Just use the command constant (UnitOn, Dim, etc.) instead. But knowing the codes leads to
some interesting possibilities. For example, XORing a UnitOn command with the value
%1000 turns it into a UnitOff command, and vice-versa. This makes it possible to write the
equivalent of an X-10 “toggle” instruction.
Here is an example of the XOUT instruction:
Mpin PIN 0 ' modulation pin
Zpin PIN 1 ' zero-cross input
HouseA CON 0 ' House code A = 0
Unit1 CON 0 ' Unit code 1 = 0
XOUT Mpin, Zpin, [HouseA\Unit1] ' get Unit1's attention
XOUT Mpin, Zpin, [HouseA\UNITON] ' turn it on
You can combine those two XOUT instructions into one like so:
XOUT Mpin, Zpin, [HouseA\Unit1\2, HouseA\UNITON] ' Unit 1 on.
Note that to complete the attention-getting code HouseA\Unit1 we tacked
on the normally optional cycles entry \2 to complete the command before
beginning the next one. Always specify two cycles in multiple commands
unless you’re adjusting the brightness of a lamp module.
Here is an example of a lamp-dimming instruction:
Mpin PIN 0 ' modulation pin
Zpin PIN 1 ' zero-cross input
HouseA CON 0 ' House code A = 0
Unit1 CON 0 ' Unit code 1 = 0
XOUT Mpin, Zpin, [HouseA\Unit1] ' get Unit1's attention
XOUT Mpin, Zpin, [HouseA\UNITOFF\2] ' turn it off
XOUT Mpin, Zpin, [HouseA\DIM\10] ' dim half way
C
OMBINING MULTIPLE COMMANDS.
D
IMMING LIGHTS.
A
SIMPLE XOUT EXAMPLE: TURNING AN
APPLIANCE ON
.