element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
microbit
  • Learn
  • Learning Center
  • STEM Academy
  • microbit
  • More
  • Cancel
microbit
micro:bit Blog 10 BBC micro:bit Projects in 10 Days: Day Six - Compass
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join microbit to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jlucas
  • Date Created: 3 Jun 2016 11:43 AM Date Created
  • Views 4455 views
  • Likes 20 likes
  • Comments 7 comments
  • micro:bit
  • bbc micro:bit
  • microbit
  • beginner micro:bit projects
  • bbc microbit
  • ten bbc micro:bit projects
  • beginner_microbit_projects
  • bbc_micro:bit
  • 10projects10days
Related
Recommended

10 BBC micro:bit Projects in 10 Days: Day Six - Compass

jlucas
jlucas
3 Jun 2016

About this project

 

In this project, students can learn how to turn their BBC micro:bit into a working compass by programming a simple script that displays the direction in which the device is facing on the LED array.

 

What you'll need

 

1 x BBC micro:bit

1 x Micro USB

1 x Computer or tablet

2 x AAA Batteries & Battery Holder (optional)

 

Project walkthrough

 

  • Go to the BBC micro:bit website, click 'create code' and begin a new Microsoft Block Editor project.

 

  • Begin by dragging in a 'forever' loop from the Basic commands menu on the left-hand side of the screen.

 

  • Connect a 'set [item] to' tile from the Variables menu, and rename the variable to 'Degrees' by clicking the dropdown.

 

  • Attach a 'compass heading (°)' tile from the Input menu.

 

image

 

  • Now drag in an 'if/do' tile from the Logic menu, and attach to your loop.

 

  • For 'if' attach a [0] < [0] tile, and drag a 'degrees' variable tile into the left dialog box. Set the right dialog box to [45], so that the tile reads 'If [degrees] < [45]

 

  • For 'do' attach a 'show string' tile and set the dialog box to 'N' so that the LED will display the letter 'N' (for 'North') when the device is facing at an angle of less than 45 degrees.

 

  • In the same 'if/do' tile, click the small blue cog icon to open up a pop up menu with some optional extra tiles. Drag in three 'else/if' tiles and one 'else' tile, so that your full block of code looks like this:

image

 

  • Using the same methodology, tell the device to read 'E' at angles of less than 135, 'S' at less than 225 degrees and 'W' at less than 315 degrees.

 

image

 

  • If the device is pointing at an angle greater than 315 degrees, it must be facing North. We don't need to specify the angles here - if none of the previous commands return as true, the bottom 'else' command will be enough to tell the BBC micro:bit to read 'N' by default if we tell it to.

 

image

 

  • Now run your program to test it on the emulator, hit compile to download and transfer it to your BBC micro:bit device to test it out in the real world!

 

When your students have mastered this project, encourage them to develop it by adding additional degrees of accuracy (NorthWest, NorthEast etc). They could also program the device to display different images on the LED array when the device is facing in each direction - a North star for North, the South pole for South, etc. Let us know how they get on in the comments section below.

  • Sign in to reply

Top Comments

  • kulky64
    kulky64 over 9 years ago +11
    I don't know much about programming BBC micro:bit and how this compass tile is implemented, but i think your program has the following flaw: pie slice corresponding to the north direction has only 45 degrees…
  • kulky64
    kulky64 over 9 years ago in reply to jlucas +2
    Do you know if this compass tile provides tilt compensated heading? Should be possible because BBC micro:bit has accelerometer too.
  • NigelB
    NigelB over 7 years ago +2
    A nice simple project, quick to implement, and something visual that changes according to what you do... a great little demonstrator for kids. With room, as you said, for refinements and imagination in…
  • dubbie
    dubbie over 6 years ago

    You can have some fun with this type of compass. If you use it on a desk with a large metal support underneath it is difficult to get it work properly. Great fun for watching others debug. Try putting it next to a laptop/PC with the hard disk running. It just goes mad!

     

    Dubbie

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • korn
    korn over 7 years ago

    Love this one. I recently used a similar compass in a library maker day class. I only did 4 directions to get them started. I think they liked the blinking heart one better though. Either way they want more Microbit days so its a win...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • NigelB
    NigelB over 7 years ago

    A nice simple project, quick to implement, and something visual that changes according to what you do... a great little demonstrator for kids. With room, as you said, for refinements and imagination in terms of what to do with the display. I like it, from the point of view of STEM.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 9 years ago in reply to kulky64

    Very Good catch.. I wanted to see if anybody else caught it.
    Cris

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • kulky64
    kulky64 over 9 years ago in reply to jlucas

    Do you know if this compass tile provides tilt compensated heading? Should be possible because BBC micro:bit has accelerometer too.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube