Week 2 – Meet the Accelerometers

This Microbit page introduces the accelerometers quite well:
and provides a first program:

Basic accelerometer program.py
The accelerometers measure how fast the microbit device is accelerating. Acceleration is the rate of increase of speed, and is often mentioned when people speak about cars, for example when someone says “…it accelerates well from traffic lights …” they are talking about the rate of increase of speed of the car.

When we talk about the acceleration of a car, it is ‘relative’ to the forward direction of the car. The car could also move in two other directions (measured relative to the driver sat in the front seat) – sideways (for example if it was hit by a lorry pulling out of a side road), or upwards/downwards (this would be unusual).

With the microbit, it reports acceleration along three axis:
X – tilting from left to right.
Y – tilting forwards and backwards.
Z – moving up and down.
(so a bit different as tilting isnt the same as moving in a direction, and I am used to x and y being at right angles, like the axis on a graph )

From what we were saying above, we might expect that if the microbit was sitting still on a table, it would not be accelerating in any direction.

When you run the program above, you need to ‘Open Serial’ to look at the values printed out, which shows the three values:
x, y and z values from the accelerometers
The interesting thing about this first program was that when the microbit was perfectly still, and importantly flat on a table, with the lights down, the ‘absolute’ (ie ignoring whether they are positive or negative) values for x/y/z were:
x: about 8
y: about 60
z: about 1000

I think I can explain these: the x- and y- values are not zero as the microbit does not sit exactly flat on my desk. If I tilt the microbit up or down from the side, I can change the x-value, and similarly, tilting it up and down, it changes the y-value.

The x- and y- values change a small amount every time they are output (and the numbers are always divisible by 4), but we can ignore this for now.

I can also explain the z value – this is the because gravity is acting on the micro bit. Having looked it up, an accelerometer is a tiny weight on a tiny spring, the more it moves, the more the current it generates. This video gives an explanation.

If I tilt the microbit, I can get the y value to zero, and again, if I tilt it sideways, I can get the x-value to zero.

Leave a comment