This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Read data from the accelerometer sensor on BBC micro:bit board


[data] = readAcceleration(obj)



[data] = readAcceleration(obj) reads data from the accelerometer sensor connected to the BBC micro:bit board, specified as a microbit object.


collapse all

Create a connection to the BBC micro:bit hardware connected to the COM4 port, and read the acceleration along the three axes of the BBC micro:bit hardware port.

>>m = microbit('COM4');
>>[data] = readAcceleration(m)

data = 

   0.0781 -8.0124 0.0273

Input Arguments

collapse all

BBC micro:bit hardware connection, specified as a microbit object, created with the microbit function.

Output Arguments

collapse all

Three-dimensional accelerometer data from the BBC micro:bit board measured along the x-, y-, and z- axes, relative to the position of the board, and specified in ㎨.

Introduced in R2017b