Arduino_LSM6DSOX - readAcceleration()

Query the IMU’s accelerometer and return the acceleration in g’s.

Syntax

IMU.readAcceleration(x,y,z)

Parameters

  • x: float variable where the acceleration value in the IMU’s x-axis will be stored.
  • y: float variable where the acceleration value in the IMU’s y-axis will be stored.
  • z: float variable where the acceleration value in the IMU’s z-axis will be stored.

Returns

1 on success, 0 on failure.

Example

float x, y, z;

if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);

    Serial.print(x);
    Serial.print('\t');
    Serial.print(y);
    Serial.print('\t');
    Serial.println(z);
}

See also