pxt-calliope/docs/reference/pins/i2c-write-number.md
Galen Nickel 985ad3d8e3 Add and update I2C topics (#602)
* Add and update I2C topics

* Throw in some edits for the serial buffer apis

* Add an example to serial read buffer
2017-12-11 22:34:33 -08:00

1.1 KiB

i2c Write Number

Write a number to a device at an I2C address using a specified number format.

pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE, true);

~hint

Simulator

This function needs real hardware to work with. It's not supported in the simulator.

~

Parameters

  • address: the 7-bit I2C address of the device to send to send value to.
  • value: the number to send to address.
  • format: the NumberFormat for value.
  • repeated: if true, a repeated start condition is set to help make sure the number is written to the device with out an interruption. If set to false (the default), the data is written without setting a start condition more than once.

Example

Send the value 2055 to the 7-bit I2C address as a 32-bit number. The 32, big-endian, and integer chosen for the format.

pins.i2cWriteNumber(32, 2055, NumberFormat.Int32BE);

See also

What's I2C?, number format