BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – I2CIN
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 219
Figure 5.8: Example Circuit for the
I2CIN command and a 24LC16B
EEPROM.
Note: The 4.7 k
resistors are required for the
I2CIN command to function
properly.
Vss
P1
Vdd
4.7 k
P0
24LC16B
(DIP)
4.7 k
SDA
SCL
1
2
3
4
8
7
6
5
The I2CIN command's InputData argument is similar to the SERIN
command's InputData argument. This means data can be received as
ASCII character values, decimal, hexadecimal and binary translations and
string data as in the examples below. (Assume the 24LC16B EEPROM is
used and it has the string, "Value: 3A:101" stored, starting at location 0).
value VAR Byte(13)
I2CIN 0, $A1, 0, [value] ' receive the ASCII value for "V"
I2CIN 0, $A1, 0, [DEC value] ' receive the number 3
I2CIN 0, $A1, 0, [HEX value] ' receive the number $3A
I2CIN 0, $A1, 0, [BIN value] ' receive the number %101
I2CIN 0, $A1, 0, [STR value\13] ' receive the string "Value: 3A:101"
Table 5.33 and Table 5.34 below list all the available special formatters and
conversion formatters available to the I2CIN command. See the SERIN
command for additional information and examples of their use.
Table 5.33: I2CIN Special
Formatters.
Special Formatter Action
SKIP Length Ignore Length bytes of characters.
SPSTR L
Input a character stream of length L bytes (up to 126) into
Scratch Pad RAM, starting at location 0. Use GET to retrieve
the characters.
STR ByteArray \L {\E}
Input a character string of length L into an array. If specified,
an end character E causes the string input to end before
reaching length L. Remaining bytes are filled with 0s (zeros).
WAITSTR ByteArray {\L}
Wait for a sequence of bytes matching a string stored in an
array variable, optionally limited to L characters. If the
optional L argument is left off, the end of the array-string must
be marked by a byte containing a zero (0).
R
ECEIVING FORMATTED DATA.