2016-03-25 16:47:20 -07:00
# Acceleration
2017-09-06 14:39:33 -07:00
Get the acceleration value (milli g-force) in one of three dimensions, or the combined force in all directions (x, y, and z).
2016-03-25 16:47:20 -07:00
2016-11-01 17:44:37 -07:00
Find the acceleration of the @boardname @ (how fast it is speeding up or slowing down).
2016-06-10 16:13:37 -07:00
2016-03-25 16:47:20 -07:00
```sig
input.acceleration(Dimension.X);
```
2016-06-10 16:13:37 -07:00
## ~hint
2016-03-25 16:47:20 -07:00
2016-06-10 16:13:37 -07:00
You measure acceleration with the **milli-g** , which is 1/1000 of a **g** .
A **g** is as much acceleration as you get from Earth's gravity.
2016-03-25 16:47:20 -07:00
2016-06-10 16:13:37 -07:00
## ~
2016-03-25 16:47:20 -07:00
2017-09-07 13:42:08 -07:00
## Parameters
2016-03-25 16:47:20 -07:00
2017-09-05 17:10:54 -07:00
* **dimension**: the direction you are checking for acceleration, or the total strength of force.
>`x` : acceleration in the left and right direction.< br />
`y` : acceleration in the forward and backward direction.< br />
`z` : acceleration the up and down direction.< br />
`strength` : the total of all the forces in every dimension (direction) together.
2016-06-10 16:13:37 -07:00
2017-09-07 13:42:08 -07:00
## Returns
2016-06-10 16:13:37 -07:00
2017-09-05 17:10:54 -07:00
* a [number ](/types/number ) that means the amount of acceleration. When the @boardname @ is lying flat on a surface with the screen pointing up, `x` is `0` , `y` is `0` , `z` is `-1023` , and `strength` is `1023` .
2016-03-25 16:47:20 -07:00
2017-09-07 13:42:08 -07:00
## Example: bar chart
2016-03-25 16:47:20 -07:00
2016-11-01 17:44:37 -07:00
This example shows the acceleration of the @boardname @ with a bar graph.
2016-03-25 16:47:20 -07:00
```blocks
basic.forever(() => {
2016-06-10 16:13:37 -07:00
led.plotBarGraph(input.acceleration(Dimension.X), 1023)
2016-03-25 16:47:20 -07:00
})
```
2017-09-05 17:10:54 -07:00
### Example: quake meter
2016-03-25 16:47:20 -07:00
2017-09-05 17:10:54 -07:00
Every 5 seconds, with the @boardname @ facing upward on a flat surface, show how much the earth is shaking (if at all).
```blocks
basic.forever(() => {
basic.showNumber(input.acceleration(Dimension.Strength))
basic.pause(5000)
})
```
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-06-24 15:42:21 -07:00
[set accelerometer range ](/reference/input/set-accelerometer-range ),
[compass heading ](/reference/input/compass-heading ),
[light level ](/reference/input/light-level )
2016-03-25 16:47:20 -07:00