mbed OS Blinky LED HelloWorld

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  */
00005 
00006 #include "mbed.h"
00007 
00008 
00009 // Blinking rate in milliseconds
00010 #define BLINKING_RATE     500
00011 
00012 
00013 int main()
00014 {
00015 #ifdef MBED_MAJOR_VERSION
00016     printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
00017 #endif
00018     // Initialise the digital pin LED1 as an output
00019     DigitalOut led(LED1);
00020 
00021     while (true) {
00022         led = !led;
00023         ThisThread::sleep_for(BLINKING_RATE);
00024     }
00025 }