pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://microbit.org/projects/make-it-code-it/compass-north/

t="https://cdn.sanity.io/images/ajwvhvgo/production/48780fa8baa73ec9a42b65646c0cb1da73c50380-720x360.jpg?q=95"/>Compass North | micro:bit
Skip to content

Activity

Compass North

Intermediate | MakeCode, Python | Compass, LED display | Boolean logic, Magnetism, Relational operators, Selection, Sensors, Using a compass, Variables

Step 1: Make it

What is it?

This simple compass will show you which way is North.

micro:bit showing N for North on LED display next to compass pointing 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

1from microbit import *
2compass.calibrate()
3
4while True:
5    bearing = compass.heading()
6    if bearing < 45 or bearing > 315:
7        display.show('N')
8    else:
9        display.show(' ')
10

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.
  • Add sound so it makes a noise when pointing North so someone who is visually impaired can use the compass.
Compass rose showing numerical bearings for N, S, E, W, NE, SW etc
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy