1. Programming On MakeCode

The following instructions are applied for Windows system but can also serve as a reference if you are using a different system.

1.1. Fast Start

Step 1 Connect to micro:bit

Connect the board to computer via USB cable.

Img

If the red LED on the back of the board is on, that means the board is powered. When your computer communicates with the main board via the USB cable, the yellow LED on it will flashes. For example, it will flash when you burn a “.hex” file.

Then Micro: bit main board will appear on your computer as a driver named “MICROBIT”. Please note that it is not an ordinary USB disk as shown below.

Img

Step 2 Write heartbeat program

Enter the link:online version of Makecode

Click “New Project” and you will see a “Creating a project”, fill it with “heartbeat” and click “Create √”.

Here we write programs on Google Chrome.

Img

Let’s write a micro:bit code.

You can drag some Blocks to the editing area and then run your program in Simulator as shown below. Here we demonstrate how to edit heartbeat program.

Operation video guide:

Img

Step3 Download codes

Generally, for Windows 10 APP (Get Windows 10 App)(Click), simply clicking the “Download” will directly download the code to the micro:bit board without any additional steps.

Yet for browsers, please:

Click “Download” in the editor. This will download a “hex” file, which is a format that the micro:bit board can read. After that, copy it to your micro:bit board just like you would copy a file to a USB drive. On Windows, you can also right-click on the “.hex” file and select “Send to → MICROBIT” to copy the file to the micro:bit board.

Img

Img

Or, you may directly drag the “.hex” file into MICROBIT.

Img

Img

During copying the “.hex” file to the Micro: bit, the yellow LED on the back of the board flashes. When the duplication is completed, the LED will stop flashing and remain on.

Step 4 Run porgram

After the program is uploaded to the Micro: bit, you can power it via USB cable or an external power. Then the 5 x 5 LED dot matrix displays a heartbeat pattern.

Img

Caution: When you programs each time, the driver of Micro: bit will automatically eject and return so the hex files will disappear. The board only has access to hex files rather than save them.

1.2. MakeCode

Enter Makecode Google Chrome online version . Here is its main interface.

Img

There are blocks “on start” and “forever”in the code editing area. After powering on, codes in “on start” only executes once, while those in “forever” runs cyclically.

Click “JS JavaScript” language:

Img

Switch it to “Python” language:

Img

1.3. Introduction to WebUSB Functions

As mentioned before, if your computer is Windows 10 and you have downloaded the APP MakeCode, you can quickly download codes to the board by “Download” button. We use the webUSB of Google Chrome to access the hardware device connected by USB.

Devices Pairing:

1. Connect the board to computer via USB cable.

Img

2. Click “Download” -> “” , and “Connect device”.

Img

3. “Next”.

Img

4. “Pair” .

Img

5. Then select the corresponding device and “Connect” .

Img

6. “Done”.

Img

Download Program:

After connection, click “Download” and you will see the Img becomes Img. The program is downloaded to the micro:bit board.

Img

If no device shows up for selection, please refer to Troubleshooting downloads with WebUSB. Browse the user guide to know how to update micro:bit firmware.

1.4. MakeCode Extensions Library

3.4.1 Import Library Extensions

Open makecode to enter a certain project, click Img to choose “Extensions”.

Img

Or click “Extensions” above the Advanced.

Img

Search the library you want.

Img

We provide the code files for each project containing everything you need to run a project, so you can load it directly. If you want to build code blocks by yourself, remember to add the following three extensions.

OLED Extension:

1. Click “Extensions” to add library extensions.

Img

2. Search “OLED” and click Img.

Img

Click the first oled-ssd1306 and wait for it to be added.

Img

3. Add successful:

Img

Ultrasonic sensor extension:

1. Click “Extensions” to add library extensions.

Img

2. Search “sonar” and clickImg to find and load “sonar”.

Img

3. Add successful:

Img

DHT11 sensor extension:

1. Click “Extensions” to add library extensions.

Img

2. Search “DHT11” and click Img to find and load “DHT11_DHT22”.

Img

3. Add successful:

Img

3.4.2 Update/Delete Extensions

1. Click “JavaScript” to switch to text code.

Img

2. Click “Explorer”.

Img

3. Find the “OLED” library and click Img to delete it.

Img

4. “Remove it”.

Img

It is removed.

1.5. How to Import Codes to MakeCode

Let’s take the “heatbeat” project as an example to show how to load the code.

1. Open the Web version of Makecode or the Windows 10 App Makecode, and click “Import” .

Img

2. “Import File…

Img

3. “Choose File” to import the file you want to load.

Img

4. Here we load “heartbeat.hex” .

Img

5. “Go ahead √

Img

In addition to the above method, you can also drag the the test code into the code editing area, as shown below:

Img

Wait for loading.

Img