Table 5.20: I2COUT Conversion
Formatters.
Table 5.21: I2COUT Special
Formatters.
2
T
I
C
HE
PROTOCOL FORMAT
5: BASIC Stamp Command Reference – I2COUT
Value
VAR
Value = 65
I2COUT 0, $A0, 0, [Value]
I2COUT 0, $A0, 0, [REP Value\5]
I2COUT 0, $A0, 0, [DEC Value]
I2COUT 0, $A0, 0, [HEX Value]
I2COUT 0, $A0, 0, [BIN Value]
Tables 5.20 and 5.21 list all the available conversion formatters and special
formatters available to the I2COUT command.
SEROUT commands for additional information and examples of their use.
Conversion
Formatter
DEC{1..5}
SDEC{1..5} Signed decimal, optionally fixed to 1 – 5 digits
HEX{1..4}
SHEX{1..4} Signed hexadecimal, optionally fixed to 1 – 4 digits
IHEX{1..4} Indicated hexadecimal, optionally fixed to 1 – 4 digits ($ prefix)
ISHEX{1..4}
BIN{1..16}
SBIN{1..16} Signed binary, optionally fixed to 1 – 16 digits
IBIN{1..16} Indicated binary, optionally fixed to 1 – 16 digits (% prefix)
ISBIN{1..16} Signed, indicated binary, optionally fixed to 1 – 16 digits (% prefix)
1 Fixed-digit formatters like DEC4 will pad the number with leading 0s if necessary; ex:
DEC4 65 sends 0065. If a number is larger than the specified number of digits, the
leading digits will be dropped; ex: DEC4 56422 sends 6422.
2 Signed modifiers work under two's complement rules.
Special Formatter
?
ASC ?
STR ByteArray {\L}
REP Byte \L
2
The I
C protocol has a well-defined standard for the information passed at
.
the start of each transmission. First of all, any information sent must be
transmitted in units of 1 byte (8-bits). The first byte, we call the SlaveID, is
an 8-bit pattern whose upper 7-bits contain the unique ID of the device
BYTE
'send the ASCII value for "A"
'send the ASCII value for "A" five times, ie: "AAAAA"
'send two characters, "6" and "5"
'send two characters, "4" and "1"
'send seven characters, "1000001"
Type of Number
Decimal, optionally fixed to 1 – 5 digits
Hexadecimal, optionally fixed to 1 – 4 digits
Signed, indicated hexadecimal, optionally fixed to 1 – 4 digits
($ prefix)
Binary, optionally fixed to 1 – 16 digits
Displays "symbol = x' + carriage return; where x is a number.
Default format is decimal, but may be combined with
conversion formatters (ex: BIN ? x to display
"x = binary_number").
Displays "symbol = 'x'" + carriage return; where x is an ASCII
character.
Send character string from an array. The optional \L argument
can be used to limit the output to L characters, otherwise,
characters will be sent up to the first byte equal to 0 or the end
of RAM space is reached.
Send a string consisting of Byte repeated L times
(ex: REP "X"\10 sends "XXXXXXXXXX").
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 145
See the DEBUG and
Action
Notes
1
1,2
1
1,2
1
1,2
1
1,2
1
1,2
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?