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
main.cpp
- Committer:
- GregC
- Date:
- 2016-08-15
- Revision:
- 0:ec68cfbf0495
File content as of revision 0:ec68cfbf0495:
#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 } }