set Accelerometer Range

Set how the Adafruit Circuit Playground Express will measure g-force or acceleration (how much the Adafruit Circuit Playground Express is speeding up or slowing down). This block is used to set the most g-force you will want to measure.

input.setAccelerometerRange(AcceleratorRange.OneG);

Parameters

  • range the biggest g-force (acceleration) number you will measure: 1g, 2g, 4g, or 8g. Any bigger numbers measured by your Adafruit Circuit Playground Express are ignored. So, you won’t receive events or measurments to your program when a bigger g-force occurs.

Example

Set the highest g-force that your Adafruit Circuit Playground Express will measure up to 4 g. Then, write to serial the acceleration measured when you move the board side to side.

input.setAccelerometerRange(AcceleratorRange.FourG)
forever(() => {
    serial.writeNumber(input.acceleration(Dimension.X))
})

Simulator

This program only works when on the Adafruit Circuit Playground Express. You have to download it first before trying it out.

See also

acceleration

accelerometer