Write data to I2C peripheral device
Write Data to I2C Peripheral Device on NI USB-845x Controller
Connect to an I2C peripheral device on an NI™ USB-845x controller and write data to it.
Connect to the NI USB-845x using its serial number. In this example, the NI USB-845x controller board that is connected to the computer has the serial
controller = ni845x("01F26E0A");
Connect to an I2C peripheral device on the controller board. In this example, the
peripheral has an address of
peripheral = device(controller,I2CAddress="0x48");
Write the values
[1,2,3,4,5] to the I2C peripheral device as
peripheral — I2C peripheral device
I2C peripheral device, specified as a
write(peripheral,data) writes data to the I2C peripheral
peripheral connected to an Aardvark™ or NI USB-845x controller.
data — Data to write
numeric | character vector | string scalar
Data to write to the I2C peripheral device, specified as a row
N) or column (
N-by-1) vector of numeric
values or as a character vector or string scalar of text. Refer to the peripheral device
documentation or data sheet for more information about the commands or data you can
write to the peripheral device.
write(peripheral,1:5) writes the values
datatype — Size and format of each value
"uint8" (default) |
Size and format of each value, specified as a character vector or string.
datatype determines the number of bytes to write for each value
and the interpretation of those bytes as a MATLAB® data type. For ASCII text, you can specify
write(peripheral,data,"uint32") writes the data as
Introduced in R2023a