Using Bluetooth Grove on Arduino Mega

Hey, I'm writing this code, to connect the Arduino Mega to an applcation i've made on MIT app inventor. Basically when i press a button on my tablet, it activates the vibrator on the mega. When i first started my project i was using an Uno, and this code worked fine, but since i've changed to the mega nothing is happening. Can someone please help me to fix this!!

int Bouton;
int vibreur = 8;
etatBouton = 0;
int recvChar;

#include <SoftwareSerial.h> //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED 1

SoftwareSerial blueToothSerial(RxD, TxD);
word w; //mot qui recoit les trames emises par la tablette

void setup() {
Serial.begin(9600);

pinMode(vibreur, OUTPUT);

pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();

}

void loop() {

recevoir();
while (1) {
if (blueToothSerial.available()) { //check if there's anydata sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
Serial.print(recvChar);
if (recvChar == 118) {

digitalWrite(vibreur, HIGH);
delay(500);
digitalWrite(vibreur, LOW);
delay(200);
digitalWrite(vibreur, HIGH);
delay(500);
digitalWrite(vibreur, LOW);
delay(1500);

}
}
}
}

void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //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();
}

void recevoir() {
if (blueToothSerial.available()) {
w = blueToothSerial.read();
blueToothSerial.flush();
}
}

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7

Which pins on the Mega does SoftwareSerial work on?

On a device with 4 hardware serial ports, why are you using SoftwareSerial at all?

I'm using SoftwareSerial because before i was using an Uno, so what would i replace it by now? (on the mega)

so what would i replace it by now?

That should be as obvious as the nose on your face. WHY are you using SoftwareSerial on the UNO? You use it because it doesn't have enough hardware serial ports/instances. Well, the Mega does.

So how would declare blueToothSerial without using SoftwareSerial?

George04:
So how would declare blueToothSerial without using SoftwareSerial?

You wouldn't. You'd connect the device to two of the other RXn/TXn pins, and use Serial1, Serial2, or Serial3, depending on which pins you connect it to.

Thanks very much, i'll try that

Yeah it works, thanks so much!!

Heyho I just recently started working with an arduino Mega 2560. I also want to establish a bluetooth connection between the Grove Module I got and my Android phone with an app from app inventor. Furthermore I want to recieve the Temperature sensor data from the arduino on my phone.

Can you maybe explain how you managed to get things working?

I can see the sensor Data in the Serial Monitor but it somehow wont transmit it to my phone....

Thanks very much for infotmation. Everything works