Login

Please fill in your details to login.





micro:bit - accelerometer

This page is mainly about micro:bit - accelerometer
Accelerometer

As well as registering 'gestures', the micro:bits accelerometer will also measure accurately the position of the device in three dimensions (in milligravities, mg), along the x-axis (tilt left and right), along the y-axis (tilt forward and backward) and along the z-axis (face up or face down). The limits of the values for the accelerometer in either axis are -2048mg to +2048mg, although this range can be changed. Accelerometers are used in mobile phones to detect screen orientation (portrait / landscape) and to control games by tilting the phone.

image
It's a bit complicated

BL / JS / PY : The easiest way to see this in action is to draw a graph (up to 1023) of the accelerometer reading. Create a simple script which plots a graph of the 'x' accelerometer reading. NOTE : The graphing function cannot show negative numbers so -1023 looks the same as +1023. The best way to see the actual readings is to use Putty to monitor the serial port of the micro:bit which will show the actual accelerometer reading.
BL / JS / PY : Now make similar scripts which detect the movement in the 'y' and the 'z' direction.
BL / JS / PY : Finally, make a script which can be used to change the axis which is being monitored using the hardware buttons - press button A to monitor 'x', button B to monitor 'y' and both button to monitor 'z'.
BL / JS / PY : Create a script which monitors the accelerometer strength using a graph (up to 2048). Again, you can monitor the actual accelerometer reading using Putty.

(microbit-accelerometer-x-graph)
(microbit-accelerometer-y-graph)
(microbit-accelerometer-z-graph)
(microbit-accelerometer-x-y-z-graph-buttons)
(microbit-accelerometer-strength-graph)

Last modified: October 5th, 2021
The Computing Café works best in landscape mode.
Rotate your device.
Dismiss Warning