Blink the onboard LED, and Print it's status in Serial

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 #include "mbed.h"
00002 
00003 DigitalOut led1(LED1);
00004 Serial pc(USBTX, USBRX); // tx, rx
00005 
00006 // main() runs in its own thread in the OS
00007 int main() {
00008     while (true) {
00009         led1 = !led1;
00010         pc.printf("%sLed %s\n",(led1?"":"\t"),(led1?"ON":"OFF"));
00011         wait(0.5);
00012     }
00013 }
00014