4.1.1 About MakeCode

⚠️ The following steps are operated on the Windows operating system. If you use another operating system, you can take them as a reference. Here are demonstrated on Google Chrome / Microsoft Edge.

MakeCode Programming Environment:

Open the online version of MakeCode editor.

MakeCode main interface:

Img

There are blocks “on start” and “forever” in the code editing area. When the power is plugged or reset, “on start” means that the code in the block only executes once, while “forever” implies that the code runs cyclically.

Click “JS JavaScript” to see the JavaScript code:

Img

Or click “Python” to switch to Python code:

Img

Language settings:

Img

Steps:

Step 1: Click the settings button Img.

Img

Step 2: Click “Language”.

Img

Step 3: Select the language you want. Here we set it to “English”.

Img

4.1.2 Makecode Extension Library

4.1.2.1 Add Library

⚠️ We provide code files (.hex) for each projects, so you can directly load them to the MakeCode editor. Or if you want, you can also build code blocks by yourself. Note that libraries are required when build them manually.

⚠️ Note: Copy and paste the link into the search box: https://github.com/keyestudio2019/pxt-creative-inventors-kit-master.git.

Img

Steps:

1. Click Img to select “Extensions”.

Img

Or click the “Extensions” above the Advanced blocks.

Img

2. Search key words or paste the GitHub link.

Img

3. Here we enter the URL: https://github.com/keyestudio2019/KEYES-Smart-Gamepad-master.git to the search box and click Img, and load the extension of “Smart-Gamepad”.

Img

4. Loading:

Img

5. Loaded:

Img

4.1.2.2 Update/Delete Library

⚠️ Generally, there is no need to remove libraries, unless they are not required.

Img

Steps:

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

Img

2. Click “Explorer”.

Img

3. Find the “Smart-Gamepad” and click the trash can Img to remove it.

Img

4. “Remove it”.

Img

4.1.3 MakeCode Program

4.1.3.1 Import Program in MakeCode

We take the project “heatbeat” as an example.

Img

Steps:

1. Connect the micro:bit board to your computer via micro USB cable.

Img

When the micro:bit is powered on, the red LED indicator on its back will light up.

On the micro:bit board, there is a yellow LED indicator that will flash when the board communicates with your computer through micro USB.

Open Finder(Mac) / Devices and drives(Windows), and you can see a USB drive named “MICROBIT”. Yet note that it is not a common disk!

Img

2. Click “Import”:

Img

3. And select “Import File…”.

Img

4. “Choose File” to open the file you need.

Img

5. Here we choose “heartbeat.hex”.

Img

6. “Go ahead √”.

Img

Or you can directly drag the hex file to the Makecode main interface:

Img

7. Imported:

Img

4.1.3.2 Download Code (WebUSB)

For browsers like Google Chrome/Microsoft Edge, their WebUSB allows direct access to the micro USB hardware device through online web page. Click “Connect Device” to pair the device. After that, click “Download” to load the code to the micro:bit board.

Img

Steps:

4.1.3.2.1 Pair device

1. Connect the micro:bit board to your computer via micro USB cable.

Img

2. Click the three dots “” behind the “Download” and select “Connect device”.

Img

3. “Next”.

Img

4. “Pair”.

Img

5. Connect to a “Device” and “Connect”.

Img

6. “Done” and connected.

Img

4.1.3.2.2 Download code

After connecting, click “Download” and the code will be downloaded to the micro:bit board, and Img becomes Img.

Img

⚠️ Tips

If there is no device for pairing in the interface, please see the device-webusb-troubleshoot.

If the micro:bit firmware requires an update, please see how-to-update-the-firmware.

4.1.3.3 Download Code (none WebUSB)

1. Connect the micro:bit board to your computer via micro USB cable.

Img

When the micro:bit is powered on, the red LED indicator on its back will light up.

On the micro:bit board, there is a yellow LED indicator that will flash when the board communicates with your computer through micro USB.

Open Finder(Mac) / Devices and drives(Windows), and you can see a USB drive named “MICROBIT”. Yet note that it is not a common disk!

Img

2. For browsers, please load the code to the micro:bit board as follows:

Img

Steps:

① Click the “Download” button and a “.hex” file will be downloaded, which can be read by the micro:bit board. After that, copy and paste it to the board.

For Windows, you can “Send to→MICROBIT” and load the “.hex” to the micro:bit board. During this process, the yellow indicator on the back of the board will flash. When done loaded, the indicator remains on.

Img

Img

Or you can directly drag the “.hex” file to the MICROBIT:

Img

Img

② After that, connect the micro: bit board to the computer via micro USB cable and power on, and you can see the on-board 5 x 5 LED matrix repeatedly shows Img and Img.

Img

⚠️ During each programing, the MICROBIT disk will automatically eject and return, and the .hex files you have copied to it will not be displayed. That is because the micro:bit board only receives and runs the latest uploaded program rather than stores them.