A teacher recently asked for some assistance on writing a Python script for the cyber:bot to make it navigate by compass. The use of the Micro:bit’s built-in compass is not currently documented in our tutorials, but it should be a useful robotics sensor for navigating from one side of the room to the other, solving mazes, and finding your way back to where you started.
I wasn’t quite sure how to navigate the scripting, so we’ve turned this into a contest for students who are working with the cyber:bot! Often, these contests receive only a few submittals, so chances are really good that even a working example may win a Gripper 3.0! Don’t let this become an unclaimed prize! If you’re an educator, consider giving your students this challenge. The deadline is February 19th so you’ve got well over a month.
A number of Micro:bit Python script examples can be found throughout the internet, but none of them are using the cyber:bot. These examples are very useful at calibrating the compass, displaying the results, and even applying it in a project. We’d like to see these examples applied to the cyber:bot.
Drive in a square, recalculating headings as you make turns! Starting at the position shown in the graphic above, navigate approximately one meter east, south, west, and north (back to the starting position). The exact distance of travel isn’t so important; point in the precise direction of travel using the compass and go. Display the direction of travel (N, S, E and W) on the Micro:bit’s LED display as feedback. The code should also have a section to show current heading in degrees using the Python editor serial terminal (this code block may be commented out so it doesn’t run as part of your navigation).
Submitting Your Entry
Submittals must be made by teachers so we’re not breaking any rules with student privacy. This is what we’d like to receive:
- Submit a zipped e-mail to email@example.com and include:
- Cyber:bot hex codes used in the Micro:bit module. Clean, formatted scripts that could be used by others. Include any calibration examples, too.
- Video demonstrating the submittal (lay a phone with a compass app or an actual compass near the start, for comparison). If video is too large for e-mail, provide a download link.
- Pictures of the robot, student, and the environment.
- Paragraph clearly explaining how the script(s) work.
- Permission to use your submittal in marketing and the cyber:bot tutorial projects section of Learn.parallax.com.
Winner Receives a Gripper 3.0!
The Gripper 3.0 is a really fun addition to the cyber:bot! This $129.00 product is entirely CNC machined in our Rocklin, California office. It’s a precise mechanical grabber that’s designed for the cyber:bot. With a Gripper 3.0, you can pick up small 3D printed objects or wooden blocks.
We haven’t actually tried to write a compass navigation script at Parallax, so we are not sure how easy this task will be – or if it will even work. One possible interference could come from the servo motors. If the servo motors are always receiving control signals while you’re checking the compass, disable signals to them while you check the compass. Using the argument of (None) instead of (0) sends no control signal to the servos. A signal of (0) is really a 1,5ms pulse every 20ms, which may cause motor movement and compass interference.