How the Project Works
How test_tilts_intro works
The accelerometer methods are part of the microbit module, so no other imports are needed. The instruction pause (1000) is always recommended at the beginning of any project that prints messages to the terminal. After that, the main loop begins.
With the accelerometer held still, a project can get information from each axis about how much it is aligned with gravity. Regardless of whether it’s acceleration (x), acceleration (y), or acceleration (z), the method call returns a value in the range of 1024 to 0 to -1024.
When the measurement is 1024, it means that the accelerometer’s sensing axis is aligned with gravity. As the sensing axis is tilted further out of alignment with gravity, the value decreases. When it’s level (pointing sideways and not at all up or down), the value is zero. As it starts to point away from gravity, the value becomes negative. When it’s aligned with gravity, but pointing the opposite direction, the value is -1024.
The accelerometer x and y values are printed, and after a 0.75 second pause, the main loop repeats.