I2CIN - BASIC Stamp Command Reference
Explanation
2
The I
C protocol is a form of synchronous serial communication developed
by Phillips Semiconductors. It only requires two I/O pins and both pins
can be shared between multiple I
the BASIC Stamp to receive data from an I
The following is an example of the I2CIN command:
Result
VAR
BYTE
I2CIN 0, $A1, 0, [Result]
This code will transmit a "read" command to an I
I/O pins 0 and 1) and then will receive one byte and store it in the variable
Result. Though it may seem strange, the I2CIN command first transmits
some data and then receives data. It must first transmit information (ID,
read/write and address) in order to tell the I
would like to receive. The exact information transmitted ($A1, 0) depends
2
on the I
C device that is being used.
The above example will read a byte of data from location 0 of a 24LC16B
EEPROM from Microchip. Figure 5.6 shows the proper wiring for this
example to work. The SlaveID argument ($A1) is both the ID of the chip
and the command to read from the chip; the 1 means read. The Address
argument (0) is the EEPROM location to read from.
The I2CIN command's InputData argument is similar to the SERIN
command's InputData argument.
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).
Page 138 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
2
C devices. The I2CIN command allows
2
C device.
SDA
P0
SCL
P1
Vdd
1
8
2
7
3
6
4
5
24LC16B
(DIP)
Vss
This means data can be received as
2
C device (connected to
2
C device what information it
Ω
4.7 k
Ω
4.7 k
A
I2CIN
.
SIMPLE
EXAMPLE
Figure 5.6: Example Circuit for the
I2CIN command and a 24LC16B
EEPROM. Note: The 4.7 KΩ Ω
resisters are required for the
I2CIN command to function
properly.
R
ECEIVING FORMATTED DATA
.
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?