Sonia Ochoa
/
ORIGINAL_bluetooth_Kl25Z
Simple program for the Bluetooth module by Seeed.
main.cpp
- Committer:
- damarisochoa
- Date:
- 2014-08-13
- Revision:
- 0:0d3565827d63
File content as of revision 0:0d3565827d63:
#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; } }