2016-03-26 00:47:20 +01:00
# Acceleration
Get the acceleration value (milli g-force), in one of three specified dimensions.
2016-11-02 01:44:37 +01:00
Find the acceleration of the @boardname @ (how fast it is speeding up or slowing down).
2016-06-11 01:13:37 +02:00
2016-03-26 00:47:20 +01:00
```sig
input.acceleration(Dimension.X);
```
2016-06-11 01:13:37 +02:00
## ~hint
2016-03-26 00:47:20 +01:00
2016-06-11 01:13:37 +02: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-26 00:47:20 +01:00
2016-06-11 01:13:37 +02:00
## ~
2016-03-26 00:47:20 +01:00
2016-06-11 01:13:37 +02:00
### Parameters
2016-03-26 00:47:20 +01:00
2016-07-15 23:53:52 +02:00
* ``dimension`` means which direction you are checking for acceleration, either `Dimension.X` (left and right), `Dimension.Y` (forward and backward), or `Dimension.Z` (up and down)
2016-06-11 01:13:37 +02:00
### Returns
2017-03-16 15:57:41 +01: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` , and `z` is `-1023` .
2016-03-26 00:47:20 +01:00
2016-06-11 01:13:37 +02:00
### Example: bar chart
2016-03-26 00:47:20 +01:00
2016-11-02 01:44:37 +01:00
This example shows the acceleration of the @boardname @ with a bar graph.
2016-03-26 00:47:20 +01:00
```blocks
basic.forever(() => {
2016-06-11 01:13:37 +02:00
led.plotBarGraph(input.acceleration(Dimension.X), 1023)
2016-03-26 00:47:20 +01:00
})
```
### See also
2016-06-25 00:42:21 +02:00
[set accelerometer range ](/reference/input/set-accelerometer-range ),
[compass heading ](/reference/input/compass-heading ),
[light level ](/reference/input/light-level )
2016-03-26 00:47:20 +01:00