Add modules to your micro:bit

In the Python language, you can use specialized instructions just for the micro:bit that are grouped into modules.  The cyberbot library archive includes several modules that will let you write micro:bit programs for your cyber:bot robot. You can read about them in the cyber:bot library reference here.

These files must be stored in a special area on your micro:bit module, called the file system.

  • Download the cyberbot library archive file:

cyberbot library archive

  • Extract the contents of the archive to a folder of your choice—you will access them from the code editor soon.

If you need instructions on how to extract files from an archive, use a search term like this in Google: How to extract an archive with Windows.  Make sure to replace Windows with Mac or Chrome if that's your computer's operating system.

Install the modules

The process is slighty different depending on which software you are using.

Using online Python editor?

  • Click the Load/Save button, and a file management dialog will appear.
  • Click the Show Files dropdown; it’s below the Project Files heading.
  • Browse into cyberbot-micropython folder you unzipped.  Select cyberbot.py and click Open.
  • Verify that cyberbot.py (and any others you choose) now appear in the file list below the microbit program (main.py).  
  • Click the file management dialog’s × shaped close button.
  • Add cyberbot import * near the top of your code in the editor area before you download or flash your project.


Now, cyberbot.py and any other added modules will be delivered to your micro:bit along with your code.

 

Using Mu editor?

  • From the folder where you extracted the cyberbot library contents, copy the contents into your computer's mu_code folder.
    • On Windows, the path is: C:\Users\<username>\mu_code
    • On Macintosh, the path is: Macintosh HD>Users>username>mu_code

  • Connect your micro:bit to your computer via USB cable.
  • Click on the Files button- a file management pane will appear at the bottom of the editor.

  • Drag and drop the cyberbot.py file (and others, if desired) from the right pane to the left pane.

Mu will transmit the file to your micro:bit.

  • Click on the Files button again to close the file management pane.
  • Add cyberbot import * near the top of your code in the editor area before you download or flash your project.

If you see a "no module named 'cyberbot'," error when flashing projects in the future, just follow these steps again the restore the micro:bit's cyberbot.py module