Accelerometer Sensor

Overview

Accelerometer Sensor componenent is used to read the values from the Accelerometer sensor of the mobile device. An accelerometer sensor measures the acceleration force in m/s2 that is applied to a device on all three physical axes (x, y, and z), including the force of gravity.

This component can be used to detect some of the motions that occur on the physical device, such as shaking, tilting etc.

Properties

Available

( Getter only ) ( Blocks only )
Type: Boolean

Gives whether the accelerometer sensor is available on the device or not. Some devices may not have this sensor and thus, before working with this sensor, it is better to check if the sensor is available for use using this block.

Enabled

( Getter + Setter )
Type: Boolean

Determines whether the Accelerometer is enabled or not. A disabled component does not execute any of the Events. It does not respond to any interactions with it by the user.

Options
true The Accelerometer is enabled and will execute Events when they occur.
false The Accelerometer is disabled and will not execute Events when they occur.

Minimum Interval

( Getter + Setter )
Type: Number

Specifies the minimum interval in milliseconds, between two consecutive phone shakes.(detected using Shaking event)

Sensitivity

( Getter + Setter )
Type: Number

Specifies how sensitive the accelerometer sensor is when measuring the values.

Options
1 Weak sensitivity
2 Moderate sensitivity
3 Strong sensitivity

XAccel

( Getter only ) ( Blocks only )
Type: Number

Gives the acceleration along the x-axis. See the description of Acceleration Changed event for more info.

YAccel

( Getter only ) ( Blocks only )
Type: Number

Gives the acceleration along the y-axis. See the description of Acceleration Changed event for more info.

ZAccel

( Getter only ) ( Blocks only )
Type: Number

Gives the acceleration along the z-axis. See the description of Acceleration Changed event for more info.

Legacy Mode

( Designer Only )
Type: Boolean

Prior to the release that added this property the AccelerometerSensor component passed through sensor values directly as received from the Android system. However these values do not compensate for tablets that default to Landscape mode.

With this property set to false, the values you receive in the compensated, corrected values. It is recommeneded that you work with the property set to false in newer apps, as this was added only to keep the older projects backward-compatible.

Methods

Accelerometer sensor component has no Methods.

Events

Acceleration Changed

( Number xAccel Number yAccel Number zAccel )

Indicates the acceleration changed in the X, Y, and/or Z dimensions.

Params
xAccel Number: Gives the acceleration along x-axis. The value is 0 when the phone is at rest on a flat surface, positive when the phone is tilted to the right (i.e., its left side is raised), and negative when the phone is tilted to the left (i.e., its right size is raised).
yAccel Number: Gives the acceleration along x-axis. The value is 0 when the phone is at rest on a flat surface, positive when its bottom is raised, and negative when its top is raised.
zAccel Number: Gives the acceleration along x-axis. The value is equal to -9.8 (earth's gravity in meters per second per second when the device is at rest parallel to the ground with the display facing up, 0 when perpendicular to the ground, and +9.8 when facing down. The value can also be affected by accelerating it with or against gravity.

Shaking

( None )

Indicates the device started being shaken or continues to be shaken.