Read one sample of angular velocity from sensor
returns one sample of the angular velocity data on x, y, and z axes read from the
sensor in units of rad/s along with the
timestamp] = readAngularVelocity(
Timestamp is optional.
readAngularVelocity function is available for the
Read Angular Velocity
Create an Arduino object and include the I2C library.
a = arduino();
Or, you can explicitly specify it in the
pair while creating the Arduino object.
clear a; a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object for the sensor in use.
The sample code and output in this example is for
object. If you are using another sensor that supports
readAngularVelocity function, use the corresponding
sensorobj = mpu9250(a);
Return one sample of angular velocity data.
gyroReadings = readAngularVelocity(sensorobj) gyroReadings = 0.0138 0.0092 0.0034
sensorobj — sensor object
The sensor object.
gyroReadings — Value read from the sensor
The angular velocity value on x, y, and z axes read from the sensor.
timestamp — Timestamp
The time at which MATLAB® receives angular velocity data from the sensor, specified as a datetime.
Code Generation Using MATLAB Function Block
readAngularVelocityin a MATLAB Function block with the Simulink® Support Package for Arduino® Hardware to generate code that can be deployed on Arduino Hardware.
Timestamp returned is always in seconds.