Need help with XBee shield + Bluetooth Bee

Hi everyone, I'm a newbie to Arduino. Currently I'm working on a robot project that can be controlled via Bluetooth from a android based phone. Following image shows my test setup. I want to control that LEDs based on some commands.


I got to know that the Bluetooth module can be accessed through the Serial interface. so, I wrote the code as this.

void setup() {

  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);

  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);

void loop() {
  if (Serial.available() > 0) {
    int data =;

    if (data == 4)
      digitalWrite(4, LOW);
    else if (data == 5)
      digitalWrite(5, LOW);
    else if (data == 6)
      digitalWrite(6, LOW);
    else if (data == 7)
      digitalWrite(7, LOW);

To test the project I'm using following android app.

But this doesn't work. What should i do? Thanks.

Are you sure your app is sending the value 4, or the ASCII symbol '4'?

@AWOL, Thanks for the reply, There was no error in the code. But the switch in the XBee shield was at the wrong position. Now it is fixed. Thanks.