Hello,
I have bought a Bluetooth shield V2 SLD63030P to realized my baccalaureat project. But with the program the constructor supply, I succeed in doing to connect the shield with the application but I can’t send a message from the application or the Arduino.
Can you help me to resolve this problem please ?
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7
#define PINLED 9
#define LEDON() digitalWrite(PINLED, HIGH);
#define LEDOFF() digitalWrite(PINLED, LOW);
#define DEBUG_ENABLED 1
String chaineRecue;
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(115200);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(PINLED, OUTPUT);
LEDOFF();
setupBlueToothConnection();
}
void loop()
{
char recvChar;
while(1)
{
recvChar = blueToothSerial.read();
chaineRecue += recvChar;
Serial.print(chaineRecue);
if(chaineRecue.indexOf("allume")>0)
{
LEDON();
}
else if(chaineRecue.indexOf("eteint")>0)
{
LEDOFF();
}
}
}
/***************************************************************************
* Function Name: setupBlueToothConnection
* Description: initilizing bluetooth connction
* Parameters:
* Return:
***************************************************************************/
void setupBlueToothConnection()
{
blueToothSerial.begin(115200);
blueToothSerial.print("AT");
delay(400);
blueToothSerial.print("AT+DEFAULT"); // Restore all setup value to factory setup
delay(2000);
blueToothSerial.print("AT+NAMESeeedBTSlave"); // set the bluetooth name as //"SeeedBTSlave" ,the length of bluetooth name must less than 12 characters.
delay(400);
blueToothSerial.print("AT+PIN0000"); // set the pair code to connect
delay(400);
blueToothSerial.print("AT+AUTH1");
delay(400);
blueToothSerial.flush();
}