In addition to drag and drop download,  Chrome based browsers (Android, Chrome OS, Linux, macOS and Windows) support direct flashing from the browser to the device over USB, more commonly known as using webUSB.  This enables you to flash your micro:bit straight from the browser without the need to save the .hex file first, and use serial communication between the micro:bit and the editor. 


Requirements

To use direct flashing from the browser, you'll need to have:


Direct flash in MakeCode

When you are ready to try your program on your micro:bit choose 'Download'. 


The following video shows the next steps if your browser supports WebUSB (e.g. Chrome and Edge browsers) as webUSB is used by default: 



The first time you do this it may take a bit longer, but subsequent flashes will be faster.

This method does not save a version of your code to your local machine, if you wish to keep a copy of the program you have written, click the save icon (looks like a floppy disk and is located next to your project name in the MakeCode Editor) to save a copy of the hex file to your local machine.


Direct flash in the Python Editor

When you are ready to try your program on your micro:bit choose 'Send to micro:bit'. 


The following video shows the next steps if your browser supports WebUSB (e.g. Chrome and Edge browsers) as webUSB is used by default: 




Check your micro:bit is attached via a USB cable to your computer then follow the steps to connect and send your program (otherwise known as 'flashing').


If your browser does not support webUSB, this video shows the alternative route to send your program to your micro:bit:


The first time you do this (either using webUSB or the alternative route) it may take a bit longer, but subsequent flashes will be faster.

Choose 'Save' to save your program to the downloads folder on your local computer. Connect your micro:bit to your computer by USB and you will see it appear like a drive in your file system. Find the saved program (i.e. in Downloads), then drag and drop it onto the MICROBIT drive to send/flash it to the micro:bit.


You can save your program as a .hex file or a .py script at any time using the save button to keep it for later. 


Using the serial console

To use the serial console you need to have a micro:bit device plugged into your computer and use a browser that supports WebUSB, currently Chrome or Edge. Connect and flash your micro:bit by clicking the “Send to micro:bit” button. Once this has been completed, you’ll see a black bar appear at the bottom of the editor. Click “Show serial” to access the serial console.

The serial console allows you to inspect text output by your program via the print() function. This is particularly useful for debugging or reviewing how the state of your program is changing over time. You are also able to input text into your program where the input() function is used.

See the Text Input and Output section within Reference inside the Python editor for more details on how to use this function. The link will not open the reference section, you will need to do this as a separate action. 


You can also interrupt and restart your program using Ctrl+C and Ctrl+D, respectively. When in an interrupted state, you can type and execute Python commands directly on your micro:bit which is a great way to try out commands with instant feedback. You can also interact with variables in your program and inspect how they have changed from their initial state when the program was started.

The serial console also shows the full output of runtime errors, which can be helpful when debugging.


For shortcuts that can be used within the serial console see: Python Editor: shortcuts.



Direct flash in MakeCode on Android with a USB OTG cable

For this to work you will need to use a USB On-the-Go cable



  1. Plug in your cable and open https://makecode.microbit.org#editor.
  2. Select the more options (three dots) menu next to the Download button and then choose Pair Device
  3. A browser pop-up will let you select your BBC micro:bit and then click Connect. You will see the USB symbol flashing on the Download button to indicate a successful connection. You may get an additional notification asking if you want to allow your Android device to communicate with the micro:bit.
  4. Select Download to instantly flash your program to the micro:bit. The first time you do this it may take a bit longer, but subsequent flashes will be faster.



Troubleshooting

Here is some troubleshooting advice for using webUSB with the micro:bit and the editors.