Lesson 4

In-built Sensors

The micro:bit has in-built sensors to measure data.


An accelerometer is a device to measure force, acceleration and angle. It is useful for sensing vibrations and orientation.


A thermometer is a device to measure temperature. It reads the temperature in degrees Celcius.


A compass is a device used for navigation. It reads the compass direction in degrees. North is 0 or 360 degrees, East is 90 degrees, South is 180 degrees and West is 270 degrees.

Task 1

  • Program the LED to display the angle when your micro:bit is tilted up and down.
  • When Button A is pressed, the angle of tilt will be displayed.

Task 2

  • Button A works the same as in Task 1.
  • When Button B is pressed, the current temperature is displayed.

Task 3

  • Buttons A and B works the same as in Task 1 and 2.
  • When Button A+B is pressed, the compass direction is displayed.