Quantcast
Channel: Seeedstudio Forum
Viewing all articles
Browse latest Browse all 6612

FAQ of Bluetooth Shield

$
0
0
How to change the baud rate of Bluetooth Shield

1
Quote:#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7);

void setup()
{
mySerial.begin(38400);
mySerial.print("\r\n+STBD=9600\r\n");
}

void loop()
{

}


After compiling the program,the baud rate of bluetooth has been changed to 9600.

Note : The connection between mobile and Bluetooth module may be not stable while using the baud rate of 9600.

2 So you need modify the demo of Slave
Quote:#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED 1

SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();

}

void loop()
{
char recvChar;
while(1){
if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
Serial.print(recvChar);
}
if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here
recvChar = Serial.read();
blueToothSerial.print(recvChar);
}
}
}

void setupBlueToothConnection()
{
blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
Serial.println("The slave bluetooth is inquirable!");
delay(2000); // This delay is required.
blueToothSerial.flush();
}


Statistics : Posted by Jacket Chen • on Mon Jun 03, 2013 9:59 am • Replies 2 • Views 880

Viewing all articles
Browse latest Browse all 6612

Latest Images

Trending Articles



Latest Images