pxt-calliope/docs/reference/input/set-accelerometer-range.md

42 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2016-06-25 00:42:21 +02:00
# Set Accelerometer Range
2016-11-02 01:44:37 +01:00
Set up the part of the @boardname@ that measures
2016-06-25 00:42:21 +02:00
[acceleration](/reference/input/acceleration) (how much the microbit
is speeding up or slowing down), in case you need to measure high
or low acceleration.
2016-07-15 23:53:52 +02:00
```sig
input.setAccelerometerRange(AcceleratorRange.OneG);
```
2016-06-25 00:42:21 +02:00
### Parameters
2016-07-15 23:53:52 +02:00
* ``range`` means the biggest number of gravities of acceleration you
will be measuring (either `1g`, `2g`, `4g`, or `8g`). Any bigger numbers
2016-11-02 01:44:37 +01:00
will be ignored by your @boardname@, both when you are picking a
2016-07-15 23:53:52 +02:00
number of gravities, and when you are measuring acceleration.
2016-06-25 00:42:21 +02:00
### Example
2016-11-02 01:44:37 +01:00
This program says the highest acceleration that your @boardname@
2016-06-25 00:42:21 +02:00
will measure is 4G. Then it measures acceleration from side to side
until you stop the program.
```blocks
input.setAccelerometerRange(AcceleratorRange.FourG);
basic.forever(() => {
basic.showNumber(input.acceleration(Dimension.X));
});
```
#### ~hint
2016-11-02 01:44:37 +01:00
This program does not work in the simulator, only in a @boardname@.
2016-06-25 00:42:21 +02:00
#### ~
### See Also
[compass heading](/reference/input/compass-heading),
[light level](/reference/input/light-level)