0% found this document useful (0 votes)
138 views8 pages

MicroBit Final Task

This document provides instructions for making a simple compass using a micro:bit that uses the micro:bit's magnetometer to sense the Earth's magnetic field and display the direction of North. It explains how the compass works and calibrates, lists the necessary materials, provides sample code to display North based on the magnetic reading, and suggests ways to improve the compass such as increasing accuracy and adding additional directional displays.

Uploaded by

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

MicroBit Final Task

This document provides instructions for making a simple compass using a micro:bit that uses the micro:bit's magnetometer to sense the Earth's magnetic field and display the direction of North. It explains how the compass works and calibrates, lists the necessary materials, provides sample code to display North based on the magnetic reading, and suggests ways to improve the compass such as increasing accuracy and adding additional directional displays.

Uploaded by

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

Step 1: Make it

What is it?
This simple compass will show you which way is North.

How it works

 Your micro:bit has a compass sensor called a magnetometer that measures


magnetic fields. It can sense the Earth’s magnetic field and so you can use it
as a compass.
 When you first use the micro:bit compass you have to calibrate it. A little game
appears on the screen where you have to tilt the micro:bit to light up every
LED, then you’re ready to go.
 The program uses an infinite (forever) loop to keep taking compass readings
and it stores them in a variable called ‘bearing’. It then uses selection: an if…
else statement to show N for North on the LED display if the bearing is greater
(>) than 315 degrees or less than (<) 45. This means that it will show you
where North is as long as your micro:bit is pointing in roughly the right
direction.
What you need

 micro:bit (or MakeCode simulator)


 MakeCode or Python editor
 battery pack (optional)
 a planet with magnetic poles to stand on, such as Earth!

Step 2: Code it

Step 3: Improve it
 Make the compass more accurate by reducing the range of bearings: make the
number 45 smaller and 315 bigger.
 Add other points of the compass to show when the
micro:bit is pointing East, West and South. Must do it
 Can you show more directions?
 Add sound so it makes a noise when pointing North so someone who is
visually impaired can use the compass.
Test your code for all values above

1. Reflection

Place a screenshot here and explain your code


In the Micro Bit, there is a compass, first, we are setting the variable Bearing to
the compass numbers. Then, we are telling the Micro Bit that is the number
detected is greater than 45 but smaller than 315, show the letter N for North and
play a sound. If the number is not that, let the Micro Bit, detect if it is another
direction, and show the according letters.

Task 2
2. Create a code to show all numbers from 0 to 1000 using 3
inputs.
Remember: Any decimal number can be written in form of
Units, Tens, Hundreds, etc
Example: 26 = 20 + 6
587 = 500 + 80 + 7

 Press P0 to resent all variables and show the value 0


 Press Button A to add units
 Press Button B to add tens
 Press A+B to add Hundreds
 Press P1 to show the number

3. Test your code. Show to the teacher the following numbers

b) 7
c) 23
d) 112
e) 777
f) 1000
3. Place a screenshot of your code here
4. Change your code to show all negatives numbers up to -1000
5. Test your code. Show the teacher the following numbers
a. -1
b. -25
c. -100
d. -534
e. Place a screenshot of your code here
6. Explain your code and highlight the difference between code 1
positive numbers) with code 2 (negative numbers)

For the first code (positive numbers), when you start the Micro Bit, it
sets the number to 0, when you press A, the code adds 1 unit. When
you press B, the code adds 1 ten, and when you press A and B, the code
adds 100 to the number. And when you press P1, it shows you the
number string.
For the second code (negative numbers), is it the exact same thing but
instead of adding it’s subtracting the number instead.
The difference is that you subtract the numbers instead of adding.
Criteria

You will be assessed on the following criteria

1. Quality of your code


2. Testing tasks
3. Clear reflection and explanation
4. Class work, commitment, and positive attitude
5. Any improvement on your code will carry extra marks

You might also like