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.

Adding a Gyroscope to your app

To add a Gyroscope to your app:

  1. Navigate to the Blocks tab of your project.

  2. Under the App Features heading, locate Sensors.

  3. Click the ⊕ symbol next to Sensor.

  4. Select Gyroscope from the provided menu.

  5. Click Add.

You will see a settings panel where you can set:

  • The Name of the Gyroscope

  • Whether the Gyroscope is Enabled

You can either confirm your choices and create the Gyroscope, or delete the Gyroscope.

Change Settings of Gyroscope

You will see the sensors you have added to your app underneath the Sensors section of your blocks.

If you click on the ⚙ icon next to your Gyroscope, you will be able to edit its settings as seen in the panels above. You can click on your Gyroscope's name to access its drawer of blocks.

Properties

PropertyDescriptionData Type

Enabled

Toggle whether the component is functioning in your app

True/False

Blocks

Events

when Gyroscope Changes

Whenever the phone is turned, or rotated, the Changes event will fire.

Functions

Call Alpha/Beta/Gamma, call X/Y/Z

PropertyTypeDescription

Alpha

Number

Rotation about the y-axis

Beta

Number

Rotation about the x-axis

Gamma

Number

Rotation about the z-axis

PropertyTypeDescription

X

Number

Angular velocity about the X axis

Y

Number

Angular velocity about the Y axis

Z

Number

Angular velocity about the Z axis

Set/Get 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.

Last updated