Have you ever wanted to turn your classroom into a real-life adventure? With the BBC micro:bit, it's easier than you might think! In this post, we'll explore how to use the micro:bit's built-in compass to create engaging and educational activities for your students. Whether you're teaching indoors or outdoors, the compass sensor offers endless possibilities for exploration and learning.
Getting Started with the Compass Sensor
The micro:bit is a powerful classroom tool with many sensors that go unused in most classrooms. Most people focus on the buttons, accelerometer and touch sensor. However, the micro:bit is equipped with some great environmental sensors as well. The compass is one of my favorite sensors as it really helps students interact with the world around them!
The micro:bit's compass sensor measures the Earth's magnetic field, using a magnetometer. This allows it to determine direction on a 0-360° scale. To access the compass data in your code, you'll use the heading feature. (In Makecode, this is the “compass heading” block in the “Inputs” category.) This feature returns a value between 0 and 359, representing the direction in degrees (0° is north, 90° is east, 180° is south, and 270° is west). The block returns number data, which you can use anywhere a number can go in your code.
Learn more about the micro:bit compass here: https://microbit.org/get-started/features/sensors/#compass
Coding with the Compass
Here are two example codes in Makecode using the compass block.
Simple Compass Read
The code to see this number in real time is very simple. Use this code to read the number the compass heading. Remember: The micro:bit LED screen will take a few seconds to scroll multi-digit numbers across. Hold the compass flat, screen up, and still to get the most accurate reading.
Cardinal Direction Code
This code will show N, S, E, or W on the LED screen. This code uses conditional statements to identify when the micro:bit is facing within a defined range of degrees.
Indoor Adventures: Navigating the Classroom
Even without leaving the classroom, you can create exciting compass-based activities. I will often start using the compass inside, giving students a chance to orient themselves to the familiar classroom space. Here are a few ideas:
- Classroom Treasure Hunt: Hide small objects around the room and provide students with compass directions to find them. Example: Stand at the classroom door. Take 3 steps North. Take 10 steps East. Take 12 steps Northwest. Find the hidden star!
- Orientation Games: Have students use the compass to determine the direction of different objects in the room, such as the window, door, or teacher's desk. Example: What side of the room is the bookshelf on? What picture lies in the NW corner of the room?
- Compass Art: Challenge students to create compass-inspired drawings or paintings, using the compass readings to guide their strokes. Check out this CodeJoy Compass Art Worksheet.
Outdoor Explorations: Discovering the World
The micro:bit's compass is also perfect for taking your students on outdoor adventures. Getting my students out the door, experiencing computer science in the real world, is always a goal of mine. Here are some ideas for outdoor activities:
- Nature Scavenger Hunt: Create a scavenger hunt list that includes items based on compass directions. Example: Tape a notecard on the north facing sides of the trees.
- Compass-Guided Hiking: Plan a hike and use the compass to navigate along a specific course. Example: Try Orienteering for Schools & Teachers
- Geocaching with Micro:bits: Introduce your students to geocaching and have them use their micro:bits to find hidden geocaches.
Last year, we took our micro:bits on the 5th grade overnight camping trip to the Chesapeake Bay! During our experience at Echo Hill Outdoor School, I asked all my students to collect some data with their micro:bits. Amongst a variety of activities, they had to use their compass on the micro:bit to orient themselves in their tent area. Take a look at the activities we tried:
Click on an image to go to the post
Tips for Using the Compass Sensor
- Calibrate the Compass: Before using the compass, it's important to calibrate it. This ensures accurate readings. The micro:bit will prompt you to calibrate your sensor by asking you to “Tilt to Fill Screen”, having you move your micro:bit around to allow the magnetometer to sense the magnetic field of the Earth.
- Consider Magnetic Interference: Be aware that magnetic fields from nearby objects, such as metal structures or electronic devices, can interfere with the compass readings. In my classroom, students' Chromebooks had a small magnet inside on the bottom left hand corner of their device. Be sure not to measure the magnetic pull of your magnet!
- Make it Fun: The most important thing is to make learning with the compass sensor enjoyable for your students. Incorporate games, challenges, and real-world applications to keep them engaged. This is an excellent opportunity for our imaginative young students to step outside their own thoughts and interact with their surroundings!
Micro:bit in the Wild: iSpy Compass Activity
In our "Micro:bit in the Wild" course this summer, we taught this activity to 200 teachers across various grades and subjects in North America. One of our favorite activities using the compass was iSpy! We used the micro:bit’s radio function to send our compass headings back and forth to a partner. The compass heading Partner A receives tells them where to look to find the thing in the room that Partner B spied.
Here’s a video of the activity: https://x.com/huttnerk/status/1816263243947483235
Here’s the code for the activity.
If you are inspired to bring computer science outdoors with your students, be sure to share with us on social media @CodeJoyEdu on most social platforms.