Accelerometer model element

Accelerometer provides access to the built-in accelerometer (if present).

Usage

To add the Accelerometer element to your model, drag the icon element to the list of your model elements.

The element implements the following basic methods:

Example of use

accelerometer.start(); // Starts the accelerometer
var data = accelerometer.readData(); // Reads the current acceleration 
_println("The acceleration on the X component is " + data.x);
_println("The acceleration on the Y component is " + data.y);
_println("The acceleration on the Z component is " + data.z);
accelerometer.stop(); // Stops the accelerometer