Compasses
Also known as a magnetometer, a compass measures the magnetic fields and is also an essential instrument for drones and aircraft to check the direction for navigation-related applications. In Micro:bit, as shown in Figure 10.7, the compass is mounted on the board. The functionality of the compass is such that it finds North at 0 degrees and 315 degrees as North West:
Figure 10.7 – Micro:bit with a compass, illustrating directions with degrees (courtesy: https://microbit.org/projects/make-it-code-it/compass-north/)
From the figure, we can observe that South is at 180 degrees, East is at 90 degrees, and West is at 270 degrees. Hence, now, it is easier to track the direction using the compass, but first, we need to calibrate the compass. The compass.calibrate()
function is used to perform the calibration:
from microbit import * compass.calibrate()
In this process, the Micro:bit display panel will display the Tilt to fill screen message,...