# Compass

The Micro:Bit has a built-in compass that we are going to use right now!

You will learn:

• How to understand the degrees on a compass.
• How to use the compass of the Micro:Bit.

### ORIENTATION

Take a look at the example and consider the following questions:

• What should I do?
• What are the goals?
• What are the expectations?
• What can I already do?
• What do I still have to discover?

### PREPARATION

View the steps under 'perform'. Then answer the following questions:

• Which steps should I follow?
• Which steps can I follow?
• How much time do I need?
• What tools do I need?

### Perform

Do the steps one by one. Do you not remember how to do it? View the hints or download the solution.

## Displaying the degrees

A compass can measure the direction to which it points in degrees. The figure below shows the direction which corresponds with a certain degree.

The north on the compass is, for example, 0 or 360° and the east is 90°,... First, we will test the compass by displaying the degrees on the Micro:Bit. You can find the block with the degrees for the compass in the group ‘input’.
Will you test the program?
You will notice that you will first need to calibrate the compass, and that your Micro:Bit will then ask the following: “tilt to fill screen”. All the songs need to be burned onto the Micro:Bit. You can do that by tilting your screen forwards and backwards and from left to right. Your Micro:Bit is calibrated once your screen is tilted sufficiently.
Are you searching for the north?

## Arrow with direction

We now want to introduce an arrow that indicates the direction on the compass. An arrow is easier to read than the amount of degrees.
Like we said earlier, there are a few built-in images in Micro:Bit. There are also a few built-in arrows which you can find in ‘basic’.

When does an arrow need to point up? You need to pick out a field of degrees in order to do that. The figure mentioned below may help you.

Start by using a variable that you equate with the degrees. Make sure to use
an “if...then...else” block in combination with a smaller “then”block. (Logic)

## STEP 3

### INDICATING THE DIRECTION

Your Micro:Bit now shows the different wind directions. However, using only this arrow is not enough.
Your Micro:Bit has to show the wind direction in letters immediately after the arrow. (N, E, S, W)

## Refining the compass

We want to refine the compass so that we also can use north-east, north-west, south-east and south-west.
How do I know which numbers to choose? Try using the top drawing with the degrees and wind directions. You will have to draw other lines now.

## Finding the north

You now have a functioning compass. In order to make it even more user-friendly, we will make sure that once you press A, your Micro:Bit will point north.

### REFLECT

Look back at the project you just made. Ask yourself the following questions:

• Does the program work as I expected? Why / why not?
• What works well?
• What works less well?
• How can I approach it differently?