This program does not work in the simulator, only in a Calliope mini.
Set up the part of the Calliope mini that measures acceleration (how much the microbit is speeding up or slowing down), in case you need to measure high or low acceleration.
input.setAccelerometerRange(AcceleratorRange.OneG);
range
means the biggest number of gravities of acceleration you
will be measuring (either 1g
, 2g
, 4g
, or 8g
). Any bigger numbers
will be ignored by your Calliope mini, both when you are picking a
number of gravities, and when you are measuring acceleration.This program says the highest acceleration that your Calliope mini will measure is 4G. Then it measures acceleration from side to side until you stop the program.
input.setAccelerometerRange(AcceleratorRange.FourG);
basic.forever(() => {
basic.showNumber(input.acceleration(Dimension.X));
});