# 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](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LfAKkxNBiTf9-hUVp0f%2F-LfAKq11ubZzw9kwMlpm%2FScreenshot%202019-05-18%20at%2015.27.06.png?alt=media\&token=022db7f3-8781-4e58-b93f-aa810c0b5937)

## 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**.&#x20;
3. Click the ⊕ symbol next to Sensor.
4. Select **Gyroscope** from the provided menu.
5. Click **Add**.

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MMGsCOQmypJUYH0PDNJ%2F-MMGscus1Tmzgj_p_Z1B%2Fsensors.png?alt=media\&token=a7524d1d-1589-4802-94cb-df712fc62c3b)

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MMGsCOQmypJUYH0PDNJ%2F-MMGtN30eJmSdWNKCxqJ%2Fsensor-options.png?alt=media\&token=131b3d8e-7da1-48d0-96d0-a05ecadbbf32)

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.

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MJXDtfqKd4NleIDcl1u%2F-MJXEWhuyDTooKBnA4fQ%2Fimage.png?alt=media\&token=1293c2e3-3dc7-4d36-89e6-5dc26cb7bed9)

### Change Settings of Gyroscope

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

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MMGsCOQmypJUYH0PDNJ%2F-MMGtPseGdJ7VyPZ-cB9%2Fshowallsensors.png?alt=media\&token=4356df80-9b33-4631-8848-bf1a5f7aeeb5)

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

| Property | Description                                             | Data 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.&#x20;

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LswD0ARgwJYrSGlu94r%2F-LswD3Gnb-JyCse39-pk%2Fgyro_changes.png?alt=media\&token=8c1f5bbd-d47f-4ddd-9eda-5f81fad4034c)

### Functions

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

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LkBU5LYUZeIXmTXw4EZ%2F-LkBUTQIgmJBjRw2Hwm7%2Fimage.png?alt=media\&token=b3c01cd1-a8b8-4452-9f1d-a6e0a0db8924)

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXHM010I_0QovWUcLfk%2F-MXHOCmRuCMkgXJpPYmw%2Fgyro1.png?alt=media\&token=2fc281f7-edda-4c8c-8778-407839eb4c10)

| Property | Type   | Description               |
| -------- | ------ | ------------------------- |
| `Alpha`  | Number | Rotation about the y-axis |
| `Beta`   | Number | Rotation about the x-axis |
| `Gamma`  | Number | Rotation about the z-axis |

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXHM010I_0QovWUcLfk%2F-MXHOGUAjmhxD_DN1SiD%2Fgyro2.png?alt=media\&token=12cc1cb1-b7ad-4e80-8e66-c9e5b989a5ef)

| Property | Type   | Description                       |
| -------- | ------ | --------------------------------- |
| `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 `enabled`property can be used to read and write new values to the gyroscope, thus allowing you to turn it on or off.

![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MXHM010I_0QovWUcLfk%2F-MXHOhW-mewMSxutvroh%2Fgyros_enabled.png?alt=media\&token=b007dc98-5049-4cf8-a5ef-2828423a8e79)

###
