Using the Online Compiler
Setting up
-
If you have an Mbed Board:
- Plug your Mbed board into your computer, and open its USB device folder.
- Double click on the
MBED.HTML
file. This adds your Mbed board to the Online Compiler as a compilation target.
-
If you don't have a board but still want to follow the quick start:
- Go to os.mbed.com/platforms.
- Select a board.
- On the board page, click Add to your Mbed Compiler.
Importing the code
Click the button below to automatically import the example into the Online Compiler.
/* mbed Microcontroller Library
* Copyright (c) 2019 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*/
#include "mbed.h"
// Blinking rate in milliseconds
#define BLINKING_RATE 500ms
int main()
{
// Initialise the digital pin LED1 as an output
DigitalOut led(LED1);
while (true) {
led = !led;
ThisThread::sleep_for(BLINKING_RATE);
}
}
Alternatively, you may select the import button on the top left hand side of the Online Compiler screen and copy the example link into the prompt.
Compiling and flashing (programming)
-
Click Compile.
Note: To build with the Mbed OS bare metal profile, add
"requires": ["bare-metal"]
to thembed_app.json
file:{ "requires": ["bare-metal"], "target_overrides": { "*": {
The Online Compiler compiles the code into an executable file, which your browser downloads.
-
Open the folder where the executable file was downloaded, and then click and drag (or copy and paste) the file to your Mbed board's USB device folder.
-
Press the board's reset button.