Simulator: This function needs real hardware to work with. It’s not supported in the simulator.
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);
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
, don’t send a stop condition after the write. Otherwise, a stop condition is sent whenfalse
(the default).
Examples
Write a big endian number to a device
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, false);
Repeated writes
Send three byte values to a device at address 33
.
pins.i2cWriteNumber(33, 19, NumberFormat.Int32BE, true);
pins.i2cWriteNumber(33, 61, NumberFormat.Int32BE, true);
pins.i2cWriteNumber(33, 87, NumberFormat.Int32BE, false);