The Microbit_Accelerometer
component lets users configure the BBC micro:bit’s on-board accelerometer and receive one or more accelerometer samples via the appropriate methods.
The accelerometer’s report rate, or period, determines how frequently data will be sent to App Inventor.
ReadAccelerometerData
– Read a single sample of accelerometer data from the micro:bit. On successful read, the
AccelerometerDataReceived
event will be run.ReadAccelerometerPeriod
– Read the current report rate for the micro:bit accelerometer. After the period is read, it will
be received by the
AccelerometerPeriodReceived
event.RequestAccelerometerDataUpdates
– Request notifications of changes in the micro:bit’s accelerometer. Changes in the accelerometer
will be reported at a rate determined by the last period value set by a call to
WriteAccelerometerPeriod
. Accelerometer
data will be reported through the
AccelerometerDataReceived
event.StopAccelerometerDataUpdates
– Stop receiving updates from the micro:bit’s accelerometer. Note that there may be pending
messages from the device that will still be reported through the
AccelerometerDataReceived
event.WriteAccelerometerPeriod
– Use the WriteAccelerometerPeriod
method to change how frequently the micro:bit
sends accelerometer data to App Inventor. The period is measured in milliseconds. According to
the micro:bit specification, valid values are 1, 2, 5, 10, 20, 80, 160, and 640 milliseconds.
Parameters:
period
(number) — The new accelerometer reporting period, in milliseconds.AccelerometerDataReceived
– The AccelerometerDataReceived
event is run whenever accelerometer samples are
received from the micro:bit. This is usually a result of performing a
read or
request operation.
The X, Y, and Z values are in thousands of 1 Earth gravity (G=-9.8 m/s2), and so
should be scaled by 1/1000.
Parameters:
AccelerometerPeriodReceived
– The AccelerometerPeriodReceived
event is run after the micro:bit’s accelerometer
period is read from the device.
Parameters:
Accelerometer_Period
(number) — The current reporting interval for the micro:bit’s accelerometer, in milliseconds.WroteAccelerometerPeriod
– The WroteAccelerometerPeriod
event is run after the micro:bit reports its period
as requested by an earlier call to the
ReadAccelerometerPeriod
method.
Parameters:
Accelerometer_Period
(number) — The reporting period for the micro:bit’s accelerometer, in milliseconds.