Problem cofiguring Bluetooth Bee with Seeeduino Mega

Hello,
I’m new to Anrduino, so I amn’t clearly understand everything. That’s why I’m asking for help

I have Seeduino Mega, XBee Shield and Bluetooth Bee. I’ve connected them as shown on wiki page (digital pins from 0 to 7 and six ISP pins):

Seeduino Mega switched to 3.3V mode, XBee Shield’s toogle swithes positions are set to left-side

Here is Arduino sketch (copied from wiki) with the only difference: I’m using SoftwareSerial.h instead of NewSoftSerial.h library

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 11
#define TxD 12
 
SoftwareSerial blueToothSerial(RxD,TxD);
 
void setup() 
{ 
    Serial.begin(9600);          //Serial port for debugging, Comment this line if not required  
    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);
    setupBlueToothConnection();
} 
 
void loop() 
{ 
  if(blueToothSerial.read() == 'a')
  {
    blueToothSerial.println("You are connected to Bluetooth Bee");
    //You can write you BT communication logic here
  }
} 
 
void setupBlueToothConnection()
{
    Serial.print("Setting up Bluetooth link");       //For debugging, Comment this line if not required    
    blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
    delay(1000);
    sendBlueToothCommand("\r\n+STWMOD=0\r\n");
    sendBlueToothCommand("\r\n+STNA=modem\r\n");
    sendBlueToothCommand("\r\n+STAUTO=0\r\n");
    sendBlueToothCommand("\r\n+STOAUT=1\r\n");
    sendBlueToothCommand("\r\n+STPIN=0000\r\n");
    delay(2000); // This delay is required.
    blueToothSerial.print("\r\n+INQ=1\r\n");
    delay(2000); // This delay is required.
    Serial.print("Setup complete");
}
 
void sendBlueToothCommand(char command[])
{
    char a;
    blueToothSerial.print(command);
    Serial.print(command);                          //For debugging, Comment this line if not required    
    delay(3000);
 
    while(blueToothSerial.available())              //For debugging, Comment this line if not required  
    {                                               //For debugging, Comment this line if not required   
       Serial.print(char(blueToothSerial.read()));  //For debugging, Comment this line if not required  
    }                                               //For debugging, Comment this line if not required   
}

The problem is that my Arduino bluetooth isn’t disoverable by my Android smartphone or SonyEricsson phone. What’s wrong?
Thanks in advance

the code :
#define RxD 11
#define TxD 12

is wrong that if you connected XBee Shield to Seeeduino mega same as the picture . You should see carefully on the wiki of XBee Shield and Bluetooth , confirm which pin be used to Sending and receiving .

regards,
deray

Thanks for the reply.
Yes, you are right. According to XBee® Shield wiki page Arduino/Seeduino Mega XBee Tx should be connected to digital pin 51 and XBee Rx should be connected to digital pin 50, so for Seeeduino Mega we define pin 51 for receiving and pin 50 for transfering:

#define RxD 51
#define TxD 50

Now my Bluetooth Bee is visible via old phone but aren’t visible via Android smartphone. I think this is completely different problem

+STWMOD=0

OK

WORK:SLAVER

+BTSTATE:0

+BTSTATE:1

+STNA=modem

OK

WORK:SLAVER

+BTSTATE:0

+BTSTATE:1

+STAUTO=0

OK

WORK:SLAVER

+BTSTATE:0

+BTSTATE:1

+STOAUT=1

OK

WORK:SLAVER

+BTSTATE:0

+BTSTATE:1

+STPIN=0000

OK

WORK:SLAVER

+BTSTATE:0

+BTSTATE:1
Setup complete

There is another topic discussing problems with Android. As I see, my Bluetooth Bee isn’t in inquiring state. Am I right?. My Android phone is HTC Wildfire S with Android 2.3.4

Ok. Now Bluetooth Bee is in inquiring mode

+INQ=1

OK

+BTSTATE:2
Setup complete

It’s visible via another Android smartphone (Sony Ericsson Live, Android 2.3.4), but my (HTC Wildfire S) still can’t see it