![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple program for the Bluetooth module by Seeed.
Revision 0:0d3565827d63, committed 2014-08-13
- Comitter:
- damarisochoa
- Date:
- Wed Aug 13 22:42:05 2014 +0000
- Commit message:
- This is a basic program for FRDM-KL25Z using the Bluetooth module by Seeed
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 |
diff -r 000000000000 -r 0d3565827d63 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 13 22:42:05 2014 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" + +Serial bts (USBTX, USBRX); +Serial pc (USBTX, USBRX); +DigitalOut myled(LED1); + +void flushSerialBuffer() +{ + char char1 = 0; + while (bts.readable()) { + char1 = bts.getc(); + } + return; +} + + +void ComBTSetup(){ + + pc.baud(38400); + + // Initialize Baud Rate for SEEED Bluetooth module + bts.baud(38400); + + // Bluetooth module initialzation + // Adapted from Arduino sample code provided on SEEED's webpage + bts.printf("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode. STDWWMOD=1 server mode + + bts.printf("\r\n+STNA=Freescale Robot\r\n"); //set the bluetooth name as "Freescale Robot" + + bts.printf("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me + + bts.printf("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here + wait(2); // This delay is required. + bts.printf("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable + pc.printf("The slave bluetooth is inquirable!"); + wait(2); // This delay is required. + flushSerialBuffer(); + wait(2); // This delay is required. + } + + +int main() { + + + ComBTSetup(); + char temp=0; + while(1) { + temp=bts.getc(); + pc.printf("%d",temp); + // the variable temp will have what is received via bluetooth + myled = 1; + wait(1); + myled = 0; + + } +}
diff -r 000000000000 -r 0d3565827d63 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 13 22:42:05 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e \ No newline at end of file