0% found this document useful (0 votes)
11 views6 pages

Compass Microbit

Uploaded by

FAWWAZ Æ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Compass Microbit

Uploaded by

FAWWAZ Æ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

8/22/24, 4:17 PM Compass

Compass

{Introduction }
This tutorial shows you how to create a program that displays which direction the
micro:bit is pointing. Let’s get started!

{Step 1}
First, store the compass heading of the micro:bit in a variable called degrees
in the forever loop.

forever

set degrees to compass heading (°)

https://makecode.microbit.org/projects/compass 1/6
8/22/24, 4:17 PM Compass

{Step 2}
If degrees is less than 45 , then the compass heading is mostly pointing
toward North. Show N on the micro:bit.

forever

set degrees to compass heading (°)

if degrees < 45 then

show string "N"

{Step 3}
If degrees is less than 135 , the micro:bit is mostly pointing East. Show E
on the micro:bit.

https://makecode.microbit.org/projects/compass 2/6
8/22/24, 4:17 PM Compass

forever

set degrees to compass heading (°)

if degrees < 45 then

show string "N"

else if degrees < 135 then

show string "E"

{Step 4}
Go to the simulator and rotate the micro:bit logo to simulate changes in the
compass heading.

{Step 5}
If degrees is less than 225 , the micro:bit is mostly pointing South. Show S
on the micro:bit.

https://makecode.microbit.org/projects/compass 3/6
8/22/24, 4:17 PM Compass

forever

set degrees to compass heading (°)

if degrees <
‫‏‬ 45 then

show string "N"

else if degrees <


‫‏‬ 135 then

show string "E"

else if degrees <


‫‏‬ 225 then

show string "S"

{Step 6}
If degrees is less than 315 , the micro:bit is mostly pointing West. Show W
on the micro:bit.

https://makecode.microbit.org/projects/compass 4/6
8/22/24, 4:17 PM Compass

forever

set degrees to compass heading (°)

if degrees < 45 then

show string "N"

else if degrees < 135 then

show string "E"

else if degrees < 225 then

show string "S"

else if degrees < 315 then

show string "W"

{Step 7}
If none of these conditions returned true, then the micro:bit must be pointing
North again. Display N on the micro:bit.

https://makecode.microbit.org/projects/compass 5/6
8/22/24, 4:17 PM Compass

forever

set degrees to compass heading (°)

if degrees < 45 then

show string "N"

else if degrees < 135 then

show string "E"

else if degrees < 225 then

show string "S"

else if degrees < 315 then

show string "W"

else

show string "N"

{Step 9 }
If you have a micro:bit, click Download and follow the screen instructions. You
will have to follow the screen instructions to calibrate your compass.

https://makecode.microbit.org/projects/compass 6/6

You might also like