jason ji / Mbed OS mbed-os-example-blinky

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 DigitalOut led2(LED2);
00005 DigitalOut led3(LED3);
00006 DigitalOut led4(LED4);
00007 
00008 // main() runs in its own thread in the OS
00009 // (note the calls to Thread::wait below for delays)
00010 int main() {
00011         char a=1,b;
00012     while (true) {
00013         led1 = !(a^1);
00014         led2 = !(a^2);
00015         led3 = !(a^4);
00016         led4 = !(a^8);
00017         if (led1) b=1;
00018         if (led4) b=0;
00019         if (b) a=a<<1;
00020         else a=a>>1;
00021         Thread::wait(500);
00022     }
00023 }
00024