Monthly Newsletter – February 2024
February 9, 2024A Totally Tubular Guide to Starting with Text-Based Coding
February 27, 2024Hello everyone! For today’s blog, I’m proud to present to you the first of many installments of a new blog series I like to call, “The Many Talents of the micro:bit.” As you may know, the micro:bit is a tiny little computer (i.e., a “microcontroller”) packed with tons of fascinating features. Today we’ll focus on the compass feature of the micro:bit!
The micro:bit features a very small component on its back that allows it to measure the direction of Earth’s magnetic field, thus allowing it to function as a digital compass! Incorporating this compass feature into the classroom isn’t just a great way to teach students how to code; it also presents a great opportunity for students to practice their geometry skills, sharpen their knowledge of how angles are measured, and better understand how these angles correspond to the cardinal directions on a compass. Let’s take a look at how the micro:bit’s compass feature can be applied to a classroom setting.
Getting Started
Image from https://en.wikipedia.org/wiki/Circular_sector#Quadrant
Start off by instructing your students to visit https://makecode.microbit.org/ to build the simple compass code shown in the image to the right. Note: When you first start up this program on your physical micro:bit, the words “TILT TO FILL SCREEN” will scroll across the LED array on the face of the micro:bit. That’s your cue to rotate the micro:bit around in all directions until all of those LEDs are filled. This calibration process allows the micro:bit to measure Earth’s magnetic field from multiple angles, allowing it to gain its bearings and accurately display the direction that its top edge is facing.
This code will program your micro:bit to display the angle corresponding to the micro:bit’s compass heading on its LED array, with 0° corresponding to north, 90° corresponding to east, 180° corresponding to south, and 270° corresponding to west. But this isn’t really the most intuitive or user-friendly way to program our micro:bit compass. Instead of displaying the angle at which the micro:bit is pointing, how could we get our micro:bit to display the cardinal directions: north (N), east (E), south (S), and west (W)? That’s where variables and conditional statements come to the rescue!
Finding Your Direction (Get it?)
The process of turning our numerical, angular values into simple cardinal directions that can be read quickly and easily is pretty simple. The first thing we will want to do is to create a variable called “degrees” and set it equal to the compass heading within a forever block. Then, using “if/then/else” conditional statements, we can instruct our micro:bit when to display what cardinal direction.
As we can see in the image to the right, we have defined our cardinal directions according to what value is assigned to the “degrees” variable:
- When the value of “degrees” is less than 45° or greater than 315°, our micro:bit should display “N” for “north.”
- When the value of “degrees” is between 45° and 135°, our micro:bit should display “E” for “east.”
- When the value of “degrees” is between 135° and 225°, our micro:bit should display “S” for “south.”
- Otherwise (that is, if the value of “degrees” is between 225° and 315°), our micro:bit should display “W” for “west.”
This activity is a great way to demonstrate how programming concepts, like variables and compound conditional statements, can help us solve real-world problems and make code bigger, bolder, and better.
Extension and Follow-Up Activities
If you have extra time in your classroom, challenge your students to make their micro:bit compasses even more accurate by expanding upon their code and programming their micro:bits to display the ordinal directions as well: northeast (NE), southeast (SE), southwest (SW), and northwest (NW). Ask your students, “What ranges of angle values will we need to use to define both the cardinal directions and the ordinal directions in our program?”
Additionally, you can incorporate one or more follow-up activities into your lesson. Here are just a few examples:
- It’s time to play pretend! Tell your students that you’ve hidden a very valuable, very secret treasure somewhere in the classroom, adding in the hint that the treasure is located in the northmost, eastmost, southmost, or westmost region of the classroom. Then watch your treasure hunters go!
- Group students into pairs, equipping each student with a micro:bit compass. The job of the first student will be to hide an object somewhere in the school. This student will then guide the second student to the location of the hidden object using only the cardinal directions. Then have the students switch roles. This is also a fun (and educational) way to spend recess on a rainy day.
- Take a small field trip to a nature area around your school. Instruct students to take notes regarding the paths they take and the things they see along the hike, with special attention to the cardinal directions they measure with their micro:bit compasses. When you return to the classroom, have students draw a map detailing their journey. Emphasize to students that their drawings should accurately depict the directions of the paths they took and the locations of the things they saw along their hike with respect to the cardinal directions.
The micro:bit is a device that wears many hats, and helping students navigate their way through the world of coding is just one of them. I look forward to writing more entries for this blog series in the near future! If you’re looking for the best way to create this Compass Challenge activity in your classroom, look at our micro:bit Go Bundle. Happy coding!
– Dr. Jake Roark