* ECHO communication between Bluetooth and RS232 * Using mBED Landtiger Card

Dependencies:   mbed-src

Fork of HC05_Transparent_mode by Edoardo De Marchi

Committer:
edodm85
Date:
Fri Oct 18 21:28:08 2013 +0000
Revision:
1:8c500bcdcbc4
Parent:
0:44f245e8b430
Child:
2:f76f36540871
First Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edodm85 1:8c500bcdcbc4 1 /*
edodm85 1:8c500bcdcbc4 2 * Author: Edoardo De Marchi
edodm85 1:8c500bcdcbc4 3 * Date: 02-07-13
edodm85 1:8c500bcdcbc4 4 * Notes: HC05 Trasparent Mode
edodm85 1:8c500bcdcbc4 5 */
edodm85 1:8c500bcdcbc4 6
edodm85 0:44f245e8b430 7 #include "mbed.h"
edodm85 0:44f245e8b430 8
edodm85 1:8c500bcdcbc4 9 #define SERIAL_2
edodm85 1:8c500bcdcbc4 10
edodm85 1:8c500bcdcbc4 11
edodm85 0:44f245e8b430 12 Serial pc(USBTX, USBRX);
edodm85 1:8c500bcdcbc4 13 #ifdef SERIAL_1
edodm85 1:8c500bcdcbc4 14 Serial blue(p9,p10); // HC05
edodm85 1:8c500bcdcbc4 15 #endif
edodm85 1:8c500bcdcbc4 16 #ifdef SERIAL_2
edodm85 1:8c500bcdcbc4 17 Serial blue(p13,p14); // TX = P14 RX = P13
edodm85 1:8c500bcdcbc4 18 #endif
edodm85 1:8c500bcdcbc4 19
edodm85 0:44f245e8b430 20 DigitalOut myled(LED1);
edodm85 0:44f245e8b430 21 DigitalOut myled4(LED4);
edodm85 0:44f245e8b430 22
edodm85 0:44f245e8b430 23
edodm85 1:8c500bcdcbc4 24 int main()
edodm85 1:8c500bcdcbc4 25 {
edodm85 0:44f245e8b430 26
edodm85 0:44f245e8b430 27 blue.baud(9600);
edodm85 0:44f245e8b430 28 pc.baud(9600);
edodm85 1:8c500bcdcbc4 29 pc.printf("Bluetooth Start\r\n");
edodm85 1:8c500bcdcbc4 30
edodm85 1:8c500bcdcbc4 31 // echo back characters and toggle the LED
edodm85 1:8c500bcdcbc4 32 while (1)
edodm85 1:8c500bcdcbc4 33 {
edodm85 1:8c500bcdcbc4 34 if (blue.readable())
edodm85 1:8c500bcdcbc4 35 {
edodm85 0:44f245e8b430 36 pc.putc(blue.getc());
edodm85 0:44f245e8b430 37 myled = !myled;
edodm85 0:44f245e8b430 38 }
edodm85 1:8c500bcdcbc4 39 if (pc.readable())
edodm85 1:8c500bcdcbc4 40 {
edodm85 0:44f245e8b430 41 blue.putc(pc.getc());
edodm85 0:44f245e8b430 42 myled4 = !myled4;
edodm85 0:44f245e8b430 43 }
edodm85 0:44f245e8b430 44
edodm85 0:44f245e8b430 45 }
edodm85 1:8c500bcdcbc4 46 }