Gyroscope

Description

The gyroscope is capable of measuring how quickly the phone is being turned. It measures the rate of rotation of the phone and returns values in radians per second about the x axis, the y axis and the z axis. This rate of rotation is also known as the Angular Velocity, so the gyroscope can tell us the speed of rotation of the phone. By extension, if the speed of rotation is any number greater than 0, we can infer that the phone is being turned.

The x, y and z axes of a standard smartphone

โ€‹

Events

Whenever the phone is turned, or rotated, the Changes event will fire. This event returns 4 parameters for us to work with.

Parameter

Type

Returns

xRotationRate

Number

Angular velocity, about the x axis, in rad/srad/s

yRotationRate

Number

Angular velocity, about the y axis, in rad/srad/s

zRotationRate

Number

Angular velocity, about the z axis, in rad/srad/s

error

String

Error message from the sensor

Properties

By default the gyroscope sensor is turned on, but the enabledproperty can be used to read and write new values to the gyroscope, thus allowing you to turn it on or off.

Property

Type

Default

set Enabled

Bool

true

get Enabled

Bool

โ€‹

Property

Type

Description

Alpha

Number

Rotation about the y-axis

Beta

Number

Rotation about the x-axis

Gamma

Number

Rotation about the z-axis