This extension provides a self-contained developing environment for developing with MicroPython using the micro:bit platform.
It allows to initialize a project with an optional template example, to upload a python sketch (terminology borrowed from Processing) on the micro:bit, or to remove/get files from the micro:bit file system. IntelliSense for function name completion is available for both the default micro:bit functionalities and for user-specified libraries.
To see the commands for the extension, use the command palette (Windows / Linux: CTRL + Shift + P
, Mac: ⌘ + Shift + P
) and search for micro:bit-python
. You will see the following list.
Each feature is explained in the sections below.
For a video tutorial on how to use this extension, please refer to this link.
- Download and install python on your system preferably python3.
- Open VSCode and install the micro:bit python extension
- Connect the micro:bit via USB cable (make sure your cable allows for data transfer and it is not only a charging cable)
- The first time, run the command
micro:bit-python: Flash MicroPython environment on micro:bit
- Open an empty workspace (aka folder) in VSCode and run the command
micro:bit-python: Initialize the workspace
. To start, choose the hello-world sample code. - Upload your files to the micro:bit using the command
micro:bit-python: Flash sketch on the micro:bit
.
Use this command the first time you use MicroPython. It will erase the micro:bit and install the MicroPython interpreter.
The uploaded firmware is a universal firmware composed of the latest MicroPython firmware for micro:bit V1 and V2: micropython-microbit-v1.1.1.hex
and micropython-microbit-v2.1.2.hex
.
This command copies all the files from the current workspace on the micro:bit. For the command to work, there must exist a main.py
file (the starting point of your program). Furthermore, folders and files nested in folders will be ignored - only files at the root of the workspace will be copied. You can also use the shortcut CTRL + F6
(Windows / Linux) or ⌘ + F6
(Mac).
For example, in the image below, main.py
and anotherfile.py
will be flashed onto the micro:bit, while the folder microbit and all its content will be ignored.
Under the hood, flashing is achieved using the microfs script.
This command initializes the current workspace by copying a microbit folder in the workspace (used to enable VScode IntelliSense), and by prompting the user to select a template file. The user can also optionally select additional libraries for extended IntelliSense support.
For example, if the user were to pick buttons
or hello-world
from the list above, the files of these projects would be copied into the current workspace, overriding existing files.
The user can also select Empty
- in such case, no changes to files occur.
The templates are fetched from this online repository. The microbit folder is fetched from this respository, while stubs for additional libraries are fetched from here. All these stubs are based on the official micro:bit documentation.
This command manually fetches the latest example snippets from this online repository. For this command to work, you must be connected to the Internet and you must have installed git on your system.
This command shows a list of all the files stored on the micro:bit.
Under the hood, this command uses ufs ls
.
This command shows the files stored on the micro:bit file system and prompts the user to pick one to be copied on the user's workspace.
Under the hood, this command uses ufs get
.
This command removes all the files on the micro:bit files system (it will not remove the MicroPython interpreter though).
Under the hood, the command uses the ufs rm
command.
This command prompts the user to choose a file to remove from the micro:bit file system.
Under the hood, the command uses the ufs rm
command.
It shows the image with the micro:bit pinout
Open the REPL through the Serial Monitor extension (dependency).
The extension requires Python installed and in the PATH variable. Other dependencies (microfs) are taken care of automatically. For using the command Fetch examples from online
and download the latest examples, you need to have git installed on your machine.
This extension also draws some inspiration from another micro:bit python extension, which you might want to consider as an alternative.
If you want to modify this extension, fork and then clone this repository on your machine. Run npm install
, to install dependencies (need to have Node.js installed). From any javascript file, press F5
to run the extension locally in debug mode.
The SoundEffect
feature for micro:bit v2 is currently not supported. Please refer to this issue for a workaround.
For other issues, refer to the issues page. Please file any issues there.
Extension developed by MAKinteract. Stubs library for IntelliSense developed by ElTrasho3000. Icon design by Hye-Young Jo.
MIT