This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

write

Write data to I2C bus

Syntax

write(dev,dataIn)
write(dev,dataIn,precision)

Description

example

write(dev,dataIn) writes data to the I2C bus.

example

write(dev,dataIn,precision) also specifies the precision.

Examples

collapse all

Create a connection to an I2C device on Arduino hardware.

a = arduino();

Use an address to create the I2C device connection.

dev = device(a,'I2CAddress','0x55');

Write data to the I2C device.

dataIn = [0 1 2 3 4 5];
write(dev,dataIn);

Copyright 2014 The MathWorks, Inc.,

Create a connection to an I2C device on Arduino hardware.

a = arduino();

Use an address to create the I2C device connection.

dev = device(a,'I2CAddress','0x55');

Write data to the I2C device with the precision of uint16.

dataIn = [0 500];
write(dev,dataIn,'uint16');

Copyright 2014 The MathWorks, Inc.,

Input Arguments

collapse all

I2C device connection specified as a device object.

Data to write to the I2C device, specified as a scalar or vector. The range of the values in the array is based on the precision.

Data precision, specified as one of the following character vectors:

  • 'uint8'

  • 'int8'

  • 'uint16'

  • 'int16'

  • 'uint32'

  • 'int32'

  • 'uint64'

  • 'int64'

Introduced in R2014b