2016-03-25 16:47:20 -07:00
# Rotation
2016-11-01 17:44:37 -07:00
Find how much the @boardname @ is tilted in different directions.
2016-03-25 16:47:20 -07:00
```sig
input.rotation(Rotation.Roll);
```
2016-06-09 18:25:59 -07:00
## ~hint
2016-11-01 10:42:42 -07:00
The @boardname @ has a part called the **accelerometer** that can
2019-02-08 13:48:49 -08:00
check how the @boardname @ is moving. Watch this video to learn how the accelerometer works:
https://www.youtube.com/watch?v=byngcwjO51U
2016-06-09 18:25:59 -07:00
## ~
2017-09-07 13:42:08 -07:00
## Parameters
2016-03-25 16:47:20 -07:00
2016-07-15 14:53:52 -07:00
* ``kind`` means which direction you are checking: ` Rotation.Pitch` (up and down) or ` Rotation.Roll` (left and right)
2016-03-25 16:47:20 -07:00
2017-09-07 13:42:08 -07:00
## Returns
2016-03-25 16:47:20 -07:00
2019-01-02 21:52:53 -08:00
* a [number ](/types/number ) that means how much the @boardname @ is tilted in the direction you ask for. This is a value in degrees between `-180` to `180` in either the `Rotation.Pitch` or the `Rotation.Roll` direction of rotation.
2016-03-25 16:47:20 -07:00
2017-09-07 13:42:08 -07:00
## Example: @boardname@ leveler
2016-03-25 16:47:20 -07:00
2019-01-02 21:52:53 -08:00
This program helps you move the @boardname @ until it is level. When it is level, the @boardname @ shows a smiley.
2016-06-09 18:25:59 -07:00
2019-01-02 21:52:53 -08:00
If you are running this program in a browser, you can tilt the @boardname @ with your mouse.
2016-06-09 18:25:59 -07:00
```blocks
let pitch = 0;
2016-03-25 16:47:20 -07:00
basic.forever(() => {
2016-06-09 18:25:59 -07:00
pitch = input.rotation(Rotation.Pitch);
let roll = input.rotation(Rotation.Roll);
2016-03-25 16:47:20 -07:00
if (Math.abs(pitch) < 10 & & Math . abs ( roll ) < 10 ) {
2016-06-09 18:25:59 -07:00
basic.showLeds(`
. # . # .
. . . . .
. . . . .
# . . . #
. # # # .
`);
2016-03-25 16:47:20 -07:00
} else {
2016-06-09 18:25:59 -07:00
basic.showLeds(`
# . . . #
. # . # .
. . # . .
. # . # .
# . . . #
`);
}
});
2016-03-25 16:47:20 -07:00
```
2017-09-07 13:42:08 -07:00
## See also
2016-03-25 16:47:20 -07:00
2016-04-13 08:27:45 -07:00
[acceleration ](/reference/input/acceleration ), [compass-heading ](/reference/input/compass-heading )
2016-03-25 16:47:20 -07:00