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

Blinky on the Arm Mbed Online Compiler

This tutorial builds Blinky using the Arm Mbed Online Compiler, which allows you to build Mbed OS applications without installing a toolchain on your own machine.

Please create a developer account. It's free, and we don't spam.

Importing Blinky

To get Blinky into the Mbed Online Compiler, click the Import into Mbed IDE button below:

/* mbed Microcontroller Library
 * Copyright (c) 2018 ARM Limited
 * SPDX-License-Identifier: Apache-2.0

#include "mbed.h"
#include "stats_report.h"

DigitalOut led1(LED1);

#define SLEEP_TIME                  500 // (msec)
#define PRINT_AFTER_N_LOOPS         20

// main() runs in its own thread in the OS
int main()
    SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);

    int count = 0;
    while (true) {
        // Blink LED and wait 0.5 seconds
        led1 = !led1;

        if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
            // Following the main thread wait, report on the current system status
            count = 0;

You're taken to the online IDE, and the Import Program dialog box opens:

Importing Blinky

The import mechanism offers a default name, but you're free to change it. When you're done, click Import.

Viewing Blinky

The imported Blinky has two interesting parts:

  • main.cpp, where the Blinky-specific code is. You can double-click the file in the navigation pane on the left to view the code.
  • mbed-os, where the Arm Mbed OS codebase is.

Later we'll compile the code; this will take both of these parts and create a single application file from them.

Viewing the code in main.cpp

Selecting a target board

The Mbed Online Compiler can build your application to match any Arm Mbed Enabled board. However, you have to select the target board before compiling.

Adding a board to your list

To add a board to your list, go to the board's page on os.mbed.com, and click the Add to your Mbed Compiler button:

Adding a board to the Mbed Online Compiler's board list

Selecting a board

The compiler shows the current build board's name on the upper right corner:

Opening the list of boards

Click the name to change your board as needed:

Selecting a board

Compile and install

The Mbed Online Compiler builds your program as a .bin file that you can install on your board.

  1. Click Compile.

    The Compile menu; choose Compile to build and download your application

  2. The program compiles:

    Compilation progress

  3. When the compiled file is ready, it's downloaded to your default download location (or opens a Download dialog box). The file format is .bin, and the file name is the same as your program name.

  4. Connect your board to your computer over USB. Mbed boards are shown as "removable storage".

    The device is listed as MBED or DAPLINK, and its type is removable storage

  5. Drag and drop your program to the board. The board installs the program.

  6. Reset the board, and see the LED blink.

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.