Read one sample of acceleration from sensor
Create an Arduino object and include the I2C library.
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.
imu = mpu9250(a);
Return one sample of acceleration data.
accelReadings = readAcceleration(imu) accelReadings = -0.7023 0.1317 10.3968
imu— IMU sensor object
The IMU sensor object.
accelReadings— Value read from the sensor
The acceleration value on x, y, and z axes read from the sensor.
The time at which MATLAB® receives acceleration data from the sensor, specified as a datetime.
readAcceleration in 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.