In the Python language, you can use specialized instructions just for the micro:bit that are grouped into modules. A module must be stored in a special area on your micro:bit, called the file system, before its instructions can be used in a script. For example, the cyberbot library archive includes several modules that will let you write micro:bit scripts for your cyber:bot robot. You can read about them in the cyber:bot library reference here [1].
You have two options: use a .hex file template that already has the module included, or add the module to your micro:bit file system manually.
Here is a template shortcut if you are using the online python.microbit.org [2] editor and just need to get started with the cyber:bot robot quickly. Simply download the template below, open it with the Python online editor, and start coding. It already has the cyberbot module added to its project settings, so you can use its instructions in your scripts right away.
Cyberbot-template-with-blink.hex [3]
As written, this script will make the P21 light blink. Let's try this to make sure the cyber:bot system is ready:
The cyberbot-template-with-blink.hex file is a good one to open every time you start on a new cyber:bot project. Just delete the default script and replace it with whatever cyber:bot script you are working on. Make sure to update the script name before you save your work. (See Save & Edit Scripts [5].) When you reopen the file later with the micro:bit Python Editor, it will still have the module(s) it needs and be ready for the cyber:bot to run. That way, you won't have to repeat all the steps in the Adding a Module to the micro:bit Filesystem section every time.
Follow these instructions for adding a module to your micro:bit. The cyberbot.py module is used as an example. The step-by-step video and checklist instructions will guide you through creating and saving a project file that has the cyberbot module. When you start writing scripts that make the cyber:bot robot move, yoy will be able to open the file you saved, and it will have the cyberbot module ready to use.
Note: You will learn how to use this module later. For now, just note that you can also find cyberbot module documentation at: learn.parallax.com/support/reference/cyberbot-library-reference.
# Template for cyber:bot Robot from cyberbot import *
IMPORTANT: The script in these steps will only work when the micro:bit is connected to a cyber:bot board that has battery power and its power switch set to 1 or 2. So, for micro:bit-only projects, it’s best to go back to a project that does not contain the cyberbot.py module
Links
[1] https://learn.parallax.com/support/reference/cyberbot-library-reference
[2] https://python.microbit.org
[3] https://learn.parallax.com/sites/default/files/content/cyberbot/Software/cyberbot-template-with-blink.hex
[4] https://python.microbit.org/v/3
[5] https://learn.parallax.com/tutorials/robot/cyberbot/get-started-microbit-and-python/save-edit-scripts
[6] http://www.parallax.com/package/cyberbot-library-python/