Read data from I2C bus
out = read(dev,numBytes)
out = read(dev,numBytes,precision)
example
out = read(dev,numBytes) returns data read from the I2C bus based on the number of bytes.
out
dev
numBytes
out = read(dev,numBytes,precision) also specifies the data precision.
precision
collapse all
Create an Arduino object and attach an I2C device object to it.
a = arduino();
Use an address to create the I2C device connection.
dev = device(a,'I2CAddress','0x55');
Read data from the I2C device.
out = read(dev,1)
out = 4
Read data from the I2C device with the precision of uint16.
out = read(dev,1,'uint16')
I2C device connection, specified as a device object.
device
Number of bytes of data to read from the I2C device, specified as a scalar.
scalar
'uint8'
'int8'
'uint16'
'int16'
'uint32'
'int32'
'uint64'
'int64'
Data precision, specified as one of the following character vectors:
Value of data stored at the I2C device register, returned as a scalar or vector based on the precision .
vector
Use read in a MATLAB® Function block with the Simulink® Support Package for Arduino® Hardware to generate code that can be deployed on Arduino Hardware.
read
arduino | readRegister | write | writeRegister
arduino
readRegister
write
writeRegister
You have a modified version of this example. Do you want to open this example with your edits?