Gerrit Pathuis
/
HC05_KL25Z_Hello_PC
Bluetooth HC05 + KL25Z communicate with Bluetooth dongle in PC in both directions.
Revision 0:0e236e004748, committed 2017-12-02
- Comitter:
- GerritPathuis
- Date:
- Sat Dec 02 13:21:04 2017 +0000
- Child:
- 1:e73a7c99f767
- Commit message:
- Works, tested 2-12-2017
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 02 13:21:04 2017 +0000 @@ -0,0 +1,59 @@ +/* + * Author: G. Pathuis + * Date: 02-12-17 + * Notes: HC05 connected to a KL25Z + * Pair with PC use password 1234 + * + * Four wire connection + * HC05 to KL25Z + * GND to GND + * +5V to 5V + * TX to pin PTE0 + * RX to pin PTE1 + * + * Open Tera Term session to connect to KL25Z + * and + * Open second Tera Term session to read the Bluetooth + * dongle in the PC + * + * Make sute Tera Term uses 9600 baud +*/ + +#include "mbed.h" + + +Serial pc(USBTX, USBRX); +Serial blue(PTE0, PTE1); // TX, RX + +DigitalOut myled(LED1); +DigitalOut myled2(LED2); + + +int main() +{ + int i =0; + blue.baud(9600); // Default Bluetooth Baudrate + pc.baud(9600); + + pc.printf("Bluetooth Start\r\n"); + + // Write from Bluetooth to PC + for (i=0; i<10; i++) { + blue.printf("Hello PC this is the HC-05, %d\n\r", i); + myled = !myled; + } + wait(1); + + // Echo back characters and toggle the LED + while (1) { + if (blue.readable()) { + pc.putc(blue.getc()); + myled = !myled; + } + if (pc.readable()) { + blue.putc(pc.getc()); + myled2 = !myled2; + } + wait_ms(10); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 02 13:21:04 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file