This is a very simple guide, reviewing the steps required to get Blinky working on an Mbed OS platform.

Mbed OS Blinky

This example shows the use of a DigitalOut object to represent an LED and use of the nonblocking Thread::wait() call. Using nonblocking calls is good practice because Mbed OS can schedule and run other threads while the first thread is waiting.

Building this example

Building with Arm Mbed CLI

To use Mbed CLI to build this example, follow the instructions in the documentation. The instructions here relate to using the Arm Online Compiler.

To use the Online Compiler, import this code into the Online Compiler, and select your platform from the top right. Compile the code using the compile button, load it onto your board and press the reset button on the board. The code will run on the board, and you will see the LED blink.

You can find more instructions for using the Mbed Online Compiler in the documentation.

Committer:
mbed_official
Date:
Mon Nov 04 16:00:04 2019 +0000
Revision:
102:6979ad8bc0bc
Parent:
100:ec006d6f3cb6
Child:
104:f2805e857b14
Simplify application (#192)

The example project has been re-written to be simplified. It uses a delay within
a loop.

Runtime statistics has been removed and is only mentioned in the README. The
reader is invited to find out more. Runtime statistics is a topic on its own
and should not be implemented here.
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-blinky

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 82:abf1b1785bd7 1 /* mbed Microcontroller Library
mbed_official 102:6979ad8bc0bc 2 * Copyright (c) 2019 ARM Limited
mbed_official 82:abf1b1785bd7 3 * SPDX-License-Identifier: Apache-2.0
mbed_official 82:abf1b1785bd7 4 */
mbed_official 82:abf1b1785bd7 5
Jonathan Austin 0:2757d7abb7d9 6 #include "mbed.h"
mbed_official 100:ec006d6f3cb6 7 #include "platform/mbed_thread.h"
Jonathan Austin 0:2757d7abb7d9 8
Jonathan Austin 0:2757d7abb7d9 9
mbed_official 102:6979ad8bc0bc 10 // Blinking rate in milliseconds
mbed_official 102:6979ad8bc0bc 11 #define BLINKING_RATE_MS 500
mbed_official 88:bea4f2daa48c 12
mbed_official 102:6979ad8bc0bc 13
mbed_official 82:abf1b1785bd7 14 int main()
mbed_official 82:abf1b1785bd7 15 {
mbed_official 102:6979ad8bc0bc 16 // Initialise the digital pin LED1 as an output
mbed_official 102:6979ad8bc0bc 17 DigitalOut led(LED1);
mbed_official 82:abf1b1785bd7 18
Jonathan Austin 0:2757d7abb7d9 19 while (true) {
mbed_official 102:6979ad8bc0bc 20 led = !led;
mbed_official 102:6979ad8bc0bc 21 thread_sleep_for(BLINKING_RATE_MS);
Jonathan Austin 0:2757d7abb7d9 22 }
Jonathan Austin 0:2757d7abb7d9 23 }