Digital Compass Explorer Using BBC micro
Overview
The Digital Compass Explorer is an exciting STEM project that uses the BBC micro’s built-in compass sensor, also called a magnetometer, to determine direction. Students calibrate the compass, observe North, South, East and West on the LED display, and learn how Earth’s magnetic field helps with navigation.
This digital compass project combines programming, electronics, magnetism, and geography in an engaging activity suitable for beginners and classroom STEM learning.
Innovation
Instead of using a traditional magnetic compass, this project transforms the BBC micro into a programmable digital compass that provides interactive visual feedback. Students can also extend the project by creating navigation challenges, direction-based games, and simple treasure-hunt activities.
Materials Required
- BBC micro
- USB cable
- Computer with Microsoft MakeCode
- Battery pack (optional)
Learning Objectives
By completing this project, students will:
- Understand the basic principles of magnetism and compass sensors.
- Learn how a digital compass uses a sensor to determine direction.
- Understand event-based and block-based programming.
- Learn how to display information on the micro LED matrix.
- Create and use variables in a program.
- Learn how to calibrate and test a digital sensor.
- Connect programming concepts with real-world navigation.
Detailed Block-Based Coding Logic
Step 1: Create a New Project
Open Microsoft MakeCode and create a new project named Digital Compass Explorer.
The MakeCode editor provides a simple drag-and-drop programming environment where students can create programs without typing traditional programming code.
This makes the digital compass project suitable for students who are new to coding and micro programming.
Step 2: Add the On Start Block
The On Start block contains instructions that execute once when the micro is powered on or reset.
Inside the On Start block, add:
Input → Calibrate Compass
When the program starts, the micro asks the user to calibrate the compass. The user follows the instructions shown on the LED display by tilting and rotating the micro as instructed.
Purpose of Calibration
It helps to:
- Activate and calibrate the built-in magnetometer.
- Improve directional accuracy.
- Reduce errors caused by magnetic interference.
Important: Keep the micro away from magnets, speakers, metal objects, and other sources of magnetic interference during calibration and testing.
Step 3: Create a Variable
Navigate to
Variables → Make a Variable
Create a variable named:
Heading
The variable stores the compass heading measured in degrees.
Example values:
- North = 0°
- East = 90°
- South = 180°
- West = 270°
Purpose
Variables temporarily store information that the program continuously updates.
Step 4: Add the Forever Block
Drag the Forever block into the workspace.
Everything inside this block repeats continuously while the Micro:bit is powered on.
Purpose
This is important because the digital compass needs to keep checking the direction as the user rotates the device
Step 5: Read the Compass Heading
Inside the Forever block add:
Set Heading to Compass Heading
The compass sensor constantly measures Earth’s magnetic field and returns a value between 0° and 359°.
Example:
- Facing North → 3°
- Facing East → 89°
- Facing South → 182°
- Facing West → 271°
The variable Heading is updated every fraction of a second.
Step 6: Detect North
Insert an If block.
Condition:
Heading < 45
OR
Heading ≥ 315
If this condition is true:
Show String “N”
Explanation
North occupies the range from approximately:
315°–359°
And
0°–44°
The digital compass now displays N whenever the micro is pointing approximately North.
Both ranges are combined because compass headings wrap around after 359°.
Step 7: Detect East
Add an Else If block.
Condition:
Heading ≥45
AND
Heading <135
Then
Show String “E”
Whenever the digital compass heading falls between these values, the Micro:bit displays E.
Step 8: Detect South
Insert another Else If block.
Condition
Heading ≥135
AND
Heading <225
Display
Show String “S”
The digital compass now identifies when the Micro:bit is facing South.
Step 9: Detect West
Insert one more Else If block.
Condition
Heading ≥225
AND
Heading <315
Display
Show String “W”
The Micro:bit now recognizes the West direction.
At this point, the digital compass can recognize all four main cardinal directions: North, East, South, and West.
Step 10: Repeat Continuously
Since everything is inside the Forever loop, the Micro:bit constantly performs the following sequence:
- Read the compass sensor.
- Store the heading.
- Compare the heading with directional ranges.
- Display N, E, S, or W.
- Repeat.
This allows the digital compass to provide real-time directional feedback as the student rotates the micro.
Working Principle
The built-in magnetometer measures Earth’s magnetic field. The program converts the heading into the nearest cardinal direction and displays it.
Applications
This project can introduce students to real-world applications of a digital compass, including:
- Navigation education
- Robotics
- Outdoor orientation activities
- Geography lessons
- Sensor-based programming
- STEM demonstrations
- Navigation games
- Beginner electronics projects
FAQs
1. What sensor does the micro use for this project?
The micro uses a built-in magnetometer, which detects magnetic fields and provides compass heading information.
2. Why does the compass need calibration?
Calibration helps improve the reliability of the compass readings and reduces the effects of magnetic interference.
3. Can metal objects affect the readings?
Yes. Magnets, metal objects, speakers, electronic devices, and other sources of magnetic interference can affect compass readings.
4. Can the micro show the heading in degrees?
Yes. The compass heading can be read as a value from approximately 0° to 359°.
5. Does this project require GPS?
No. The digital compass uses the micro’s magnetometer to determine direction and does not require GPS.
6. Can the project work using a battery?
Yes. After transferring the program to the micro, a compatible battery pack can be used to run the project without the USB cable.
7. Is this project suitable for beginners?
Yes. The project uses Microsoft MakeCode’s block-based programming environment and is suitable for students who are beginning to learn coding and sensors.
8. What concepts do students learn?
Students explore magnetism, sensors, variables, conditional statements, loops, compass directions, and block-based programming.
Key Takeaway
A digital compass is a great example of how science, technology, engineering, and programming can come together in one hands-on STEM activity. With a BBC micro and a few simple blocks of code, students can build, test, and experiment with their own programmable navigation device.
















