Students will…
Refer to details and examples in a text when explaining what the text says explicitly and when drawing inferences from the text.
Interpret information presented visually, orally, or quantitatively (e.g., in charts, graphs, diagrams, time lines, animations, or interactive elements on Web pages) and explain how the information contributes to an understanding of the text in which it appears.
Integrate information from two texts on the same topic in order to write or speak about the subject knowledgeably.
In the book, Roz faces many situations that require her to be able understand her location and where her destination is located. Whether she is working around the farm or working to find her island robots are built with sensors and bits of code to help them understand where they are located.
Your challenge is to learn how to code your very own compass using the Micro:bit. As you learn key principles about how a compass works and how to code the Micro:bit to make it work you will be challenged with some new ideas to apply your learning!
Let's get started so you don't get lost in your journey!
In this guide, I will show you how we can use our Micro: bit as a compass by being able to see the directions based on the angle we read from the Micro: bit.
We are going to read the value from the sensor that is built within the Micro: bit. This is called magnetometer. The Micro:bit's built-in magnetometer chip is intended for use as compass to detect magnetic north. Like the compass app on your phone, this requires calibration. How it works is that it detects the earth's magnetic field along three perpendicular axes, X, Y and Z.
Locate the Magnetometer on your Micro:bit so you understand where it can be found.
Before we begin to code we must divide up the angles of Earth so that we can create an accurate compass. Remember, our Micro: bit is only as smart as we are so we have to help it decide on the directions. For the sake of learning we will use the image below to create our coordinates for our compass. Your job is to create the trigger zones in MakeCode based on these degree readings. We are basically going 20 degrees in both directions of the four cardinal directions.
Let us start to code the Micro: bit for this.
Go to makecode.microbit.org and create a new project and choose a forever block there.
Go to the Logic block and choose If Then block. We need to click the gear and add the Else block. These need to be embedded inside the Forever block. We also need to add an AND-OR block to our If Then block.
Once we have our logic blocks inserted we need to begin to add the blocks necessary to do the compass calculations. The first thing we need to do is activate the compass reading so we can make decisions. Head to Input and find the compass heading block. This block reads the values from the compass OR we can use the magnetometer which is built right into the Micro:bit.
This part is very important for your learning and understanding. Especially when we dive into the next challenge. At this point we need the Micro:bit to make decisions based on the integer value it is reading. Looking at the image above we have started to create Logical Operators to compare and make decisions.
Are you still with me?
What we need is to create the values that will help the Micro:bit find to be TRUE to create an output(in our case it will be N,S,E,W). If the values are not TRUE or FALSE, then nothing will happen.
Think of it this way in the form of a table
For our coding purposes we will be focusing on the A AND B column for our project and the A OR B column. We are going to code these conditions to show the direction we are facing.
How do we do this?
Look at the image above. This is the code for North. Don't copy it yet!
Wait.
Pause.
Read on my good friend.....
When you look at the image we have two sides. To keep it simple we have the LEFT side which is the part of the If line that is to the left of the OR command. We have the RIGHT side which is to the right of the OR command.
Left will be equal to A on our table
Right wil be equal to B on our table
**Don't get this confused with the A and B button on the Micro:bit
By looking at the code above you will see that we have added 340 degrees for A and 20 for B. We have two ways of detecting North which is why we have chosen OR instead of AND. And would mean that both A and B would need to be true. Or allows us to only have one be true.
In this case
I provided the N,S,E,W trigger zones at the very top in case you are wondering where I got these numbers.
How did I code this North command? Check it out below.
This is a mini challenge to you. See if you can actually figure out how to do the other three cardinal directions.
A couple of hints
1. You will need to duplicate the block we did for North, but change some numbers and formulas(OR AND) based on the table and direction
2. As you code in one direction download and check it. Do one step at a time!
3. If you get stuck, then I have more help here, but don't click on this until you have tried. Believe in yourself. Make that brain work! You can do it!
Now that you have this working, try programming your compass to be sensitive to directional headings such as NE, NW, SE and SW.
Can you create a cool case for your new compass?
Can you replace the N,S,E,W with symbols that represent the directions. For example a star for North to connect to North Star?
Can you create a geocache game?
Load up this Flipgrid and share your work!