Mistake on this page?
Report an issue in GitHub or email us

Using the Online Compiler

This page covers:

  1. Setting up an Mbed account and adding a development board to it.
  2. Importing the Blinky code for either the full profile or bare metal profile of Mbed OS.
  3. Compiling and flashing the code to your board.

Setting up

  1. Create an Mbed account.

  2. If you have an Mbed board:

    1. Plug your Mbed board into your computer.

      The board is listed as a USB device.

    2. Open the board's USB device folder.

    3. Double click on the MBED.HTML file. This adds your Mbed board to the Online Compiler as a compilation target.

    If your board doesn't have an MBED.HTML file, follow the instructions in the next step (for users who don't have a board). Instead of selecting any board, search for your board and select it.

  3. If you don't have a board but still want to follow the quick start:

    1. Go to os.mbed.com/platforms.
    2. Select any board.
    3. On the board page, click Add to your Mbed Compiler.

Importing the code - full profile

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.

Importing the code - bare metal profile

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"

#define WAIT_TIME_MS 500 
DigitalOut led1(LED1);

int main()
{
    printf("This is the bare metal blinky example running on Mbed OS %d.%d.%d.\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);

    while (true)
    {
        led1 = !led1;
        thread_sleep_for(WAIT_TIME_MS);
    }
}

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)

  1. Click Compile.

    Note: To build with the Mbed OS bare metal profile, add "requires": ["bare-metal"] to the mbed_app.json file:

    {
        "requires": ["bare-metal"],
        "target_overrides": {
            "*": {
    

    The Online Compiler compiles the code into an executable file, which your browser downloads.

  2. 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.

  3. Press the board's reset button.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.