Zum Hauptinhalt springen
Dein gewünschter Wiki-Artikel wurde noch nicht in deine Sprache übersetzt.

Motion Sensor

Zurück zur Artikelliste

Motion Sensor

The micro:bit has a motion sensor that combines an accelerometer and a magnetometer. The accelerometer detects movement in three directions, while the magnetometer measures magnetic fields. The sensor can detect some gestures, such as falling, directly in its hardware. Other gestures, such as logo-up, logo-down, and shaking, are detected using software.

The micro:bit also uses the accelerometer to calculate a compass reading that works regardless of the board's orientation. Before using the compass, you must calibrate it. The runtime software starts the calibration process automatically. The motion sensor communicates with the application processor through the I²C bus.

The micro:bit board supports two possible motion sensors: the ST LSM303AGR and the NXP FXOS8700CQ. Only one of these sensors is fitted on a board, and the micro-DAL automatically detects which sensor is present.

Sample Code 1

Result: Tilt the micro:bit to the right, and it should display a smiley face icon. Tilt it to the left, and it should display a heart icon.

Sample Code 2

Result: Point the micro:bit North (a heading less than 45 degrees or 315 degrees and above), and it should display the letter "N". Rotate it to the East (heading less than 135 degrees), and it should display "E". Rotate it South (heading less than 225 degrees), and it should display "S". Rotate it West (heading less than 315 degrees), and it should display "W". Turn the micro:bit around to see the letters change as it acts like a compass.

Specifications

Item details
Model LSM303AGR
Features 3 magnetic field and 3 acceleration axes , 2/4/8/16g ranges
Resolution 8/10/12 bits
On board gestures 'freefall'
Other gestures Other gestures are implemented by software algorithms in the runtime.