![](/media/cache/group/hexiweare_logo_main_black.jpg.50x50_q85.jpg)
Serial and RGB LED program example for Hexiwear
This project demonstrates the use of a Hexiwear Serial interface and the GPIOs to control the RGB LED
Open a Hyperterminal tool on your computer and connect it to the "mbed Serial port (COMxx)" with Baud rate "9600bps"
Compile the project and copy the binary "Hexi_Serial_RGB_Example_HEXIWEAR.bin" in the DAP-LINK drive from your computer file explorer Press the K64F-RESET button on the docking station to start the program on your board
Message "Tell me the RGB LED Color" will appear in the Hyperterminal window Then every 1s a color (Red, Green or Blue) will be displayed in the Hyperterminal window and the RGB LED will power-on accordingly
Diff: main.cpp
- Revision:
- 0:ec68cfbf0495
diff -r 000000000000 -r ec68cfbf0495 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Aug 15 18:15:42 2016 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "rtos.h" + +DigitalOut led_red(PTC8); +DigitalOut led_green(PTD0); +DigitalOut led_blue(PTC9); +Serial pc(USBTX, USBRX); + +int main() +{ + pc.printf("Tell me the RGB LED Color\r\n"); + + while (true) { + pc.printf("Red\r\n"); // print the value of variable i + led_red=0; + led_green=1; + led_blue=1; + Thread::wait(1000); // wait a small period of time + pc.printf("Green\r\n"); // print the value of variable i + led_red=1; + led_green=0; + led_blue=1; + Thread::wait(1000); // wait a small period of time + pc.printf("Blue\r\n"); // print the value of variable i + led_red=1; + led_green=1; + led_blue=0; + Thread::wait(1000); // wait a small period of time + + } +} +