I use seeedstudio bluetooth shield and I set it as slave. This is the code:
#include <SoftwareSerial.h>
#define RxD 6
#define TxD 7
SoftwareSerial blueToothSerial(RxD,TxD);
void setup(){
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
blueToothSetup();
}
void blueToothSetup(){
blueToothSerial.begin(38400);
blueToothSerial.print("\r\n+STWMOD=0\r\n");
blueToothSerial.print("\r\n+STNA=BluetoothSlave\r\n");
blueToothSerial.print("\r\n+STOAUT=1\r\n");
blueToothSerial.print("\r\n+STAUTO=0\r\n");
delay(2000);
blueToothSerial.print("\r\n+INQ=1\r\n");
Serial.println("BT works!");
delay(2000);
blueToothSerial.flush();
}
void loop(){
blueToothSerial.print("A");
}
I can’t write on bluetooth serial. After upload the sketch, leds of shield blink green/red but after 3 seconds the module doesn’t work and leds don’t blink.