Main Content

readAcceleration

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

Description

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

example

Examples

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 ㎨.

Version History

Introduced in R2017b