Hexiwear / Mbed OS Hexi_Serial_Rgb_Example
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 DigitalOut led_red(PTC8);
00005 DigitalOut led_green(PTD0);
00006 DigitalOut led_blue(PTC9);
00007 Serial pc(USBTX, USBRX);
00008 
00009 int main()
00010 {
00011     pc.printf("Tell me the RGB LED Color\r\n");
00012 
00013     while (true) {
00014         pc.printf("Red\r\n"); // print the value of variable i
00015         led_red=0;
00016         led_green=1;
00017         led_blue=1;
00018         Thread::wait(1000); // wait a small period of time
00019         pc.printf("Green\r\n"); // print the value of variable i
00020         led_red=1;
00021         led_green=0;
00022         led_blue=1;
00023         Thread::wait(1000); // wait a small period of time
00024         pc.printf("Blue\r\n"); // print the value of variable i
00025         led_red=1;
00026         led_green=1;
00027         led_blue=0;
00028         Thread::wait(1000); // wait a small period of time
00029  
00030     }
00031 }
00032