Table 5.96: XOUT Commands and
Their Function.
A
XOUT
:
SIMPLE
EXAMPLE
TURNING
.
AN APPLIANCE ON
C
OMBINING MULTIPLE COMMANDS
D
.
IMMING LIGHTS
5: BASIC Stamp Command Reference – XOUT
Table 5.96 lists the XOUT command codes and their functions:
Command
Value
UnitOn
%10010 Turn on the currently selected unit.
UnitOff
%11010 Turn off the currently selected unit.
UnitsOff
%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:
Zpin
CON
Mpin
CON
HouseA
CON
Unit1
CON
XOUT Mpin, Zpin, [HouseA\Unit1]
XOUT Mpin, Zpin, [HouseA\UnitOn]
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:
Zpin
CON
Mpin
CON
HouseA
CON
Unit1
CON
XOUT Mpin, Zpin, [HouseA\Unit1]
XOUT Mpin, Zpin, [HouseA\UnitOff\2, HouseA\Dim\10] 'Dim halfway.
The dim/bright commands support 19 brightness levels. Lamp modules
may also be turned on and off using the standard UnitOn and UnitOff
commands. In the example instruction above, we dimmed the lamp by
0
' Zpin is P0.
1
' Mpin is P1.
0
' House code A = 0.
0
' Unit code 1 = 0.
0
' Zpin is P0.
1
' Mpin is P1.
0
' House code A = 0.
0
' Unit code 1 = 0.
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 335
Function
' Get unit 1's attention..
' ..and tell it to turn on.
'Get unit 1's attention..
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?