Documentation

read

Read I2C data

Syntax

  • out = read(dev,numBytes,dataType)
    example

Description

example

out= read(dev,numBytes,dataType)reads data from the specified I2C device using the input number of bytes and data type.

Examples

collapse all

Read from an I2C Device

Create an I2C device object on Arduino®hardware, and read values from the device.

a = arduino(); dev = i2cdev(a,'0x48');

Read2bytes of date of typeuint16.

out = read(dev,2,'uint16');

Input Arguments

collapse all

dev— I2C device connectionobject

I2C device connection specified as an object.

numBytes— Number of bytes to readnumeric

Number of bytes of data to read form an I2C device specified as a number.

dataType— Data type to readuint8 (default) | uint16

Data type to read from an I2C device, specified as a string.

Output Arguments

collapse all

out——价值的数据numeric

Value of data in the I2C device, returned as a number or a numeric array.

Was this topic helpful?