Basic Stamp and BLINKM Code Example
schreiner
Posts: 2
I have a BLINKM LED device which speaks I2C and am having getting code to work with the BS2px using the I2COUT and I2CIN commands.· Actually I have no problems sending commands to the BLINKM using the I2COUT command but I cannot read data from the BLINKM using the I2CIN command.· I try to read the I2C address of the BLINKM but only get 0x255 in return even though the device is at address 0x01.· The I2CIN command format in the help for PBASIC is confusing because the examples do not include the slaveid parameter.
Can anyone provide sample code or clear up my thinking of the I2CIN command specifically for its use with the BLINKM device?
I was trying these instruction sequences when atempting to read the address of the BLINKM:
I2COUT 0, 1, [noparse][[/noparse]"a"]
PAUSE 100
I2CIN 0, 1, [noparse][[/noparse]dev_address1]
DEBUG dev_address1
and this sequence:
I2CIN 0, 1, $61, [noparse][[/noparse]dev_address1]
DEBUG dev_address1
·
Can anyone provide sample code or clear up my thinking of the I2CIN command specifically for its use with the BLINKM device?
I was trying these instruction sequences when atempting to read the address of the BLINKM:
I2COUT 0, 1, [noparse][[/noparse]"a"]
PAUSE 100
I2CIN 0, 1, [noparse][[/noparse]dev_address1]
DEBUG dev_address1
and this sequence:
I2CIN 0, 1, $61, [noparse][[/noparse]dev_address1]
DEBUG dev_address1
·
Comments
I2COUT <pin>,$09,<command> or I2COUT <pin>,$09,<command>,[noparse][[/noparse]<data>]
If the BLINKM is the only I2C device attached, you could use $00 instead of $09.
To read data from the BLINKM, you'd use:
I2CIN <pin>,$09,<command>,[noparse][[/noparse]<variable>]
To set a new address, you could use: I2COUT <pin>,$09,"A",[noparse][[/noparse]<new address>,$d0,$0d,<new address>]
See the BLINKM documentation for an explanation of the above
To read the BLINKM's version, you could use: I2CIN <pin>,$09,"z",[noparse][[/noparse]<major version>,<minor version>]
The stuff in <> brackets is descriptive, not to be taken literally.