Using HC-05 - Serial to Bluetooth HelloWorld Example for WIZwiki-W7500

Dependencies:   mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /**
00002  ******************************************************************************
00003  * @project HC-05_HelloWorld_WIZwiki-W7500
00004  * @author  WIZnet
00005  * @version V1.0.0
00006  * @date    01-JUL-2015
00007  * @brief   Main program
00008 *******************************************************************************
00009 **/
00010 
00011 /* Includes ------------------------------------------------------------------*/
00012 #include "mbed.h"
00013 
00014 /* Private typedef -----------------------------------------------------------*/
00015 /* Private define ------------------------------------------------------------*/
00016 /* Private variables ---------------------------------------------------------*/
00017 Serial pc(USBTX, USBRX);
00018 Serial bt(PA_14, PA_13);
00019 
00020 /* Private function prototypes -----------------------------------------------*/
00021 
00022 /* Private functions ---------------------------------------------------------*/
00023 /**
00024    * @brief  Main Function
00025    * @param  None
00026    * @retval None
00027    */
00028 int main(void)
00029 {
00030     char ch;
00031     pc.baud(115200);
00032     bt.baud(115200);
00033     pc.printf("Hello World!\n\r");
00034     bt.printf("Hello World!\r\n");
00035     
00036     while(1)
00037     {
00038         if(bt.readable())
00039         {
00040             ch=bt.getc();
00041             pc.printf("%c",ch);
00042             bt.printf("%c",ch);
00043         }
00044         
00045         else if(pc.readable())
00046         {
00047             ch=pc.getc();
00048             bt.printf("%c",ch);
00049             pc.printf("%c",ch); 
00050         }
00051     }
00052 }