Code for password-activated LED via Bluetooth serial I have this pretty simple task to light up an LED for 3 seconds when I send the right password from my Android phone to the Arduino via Bluetooth. I am using an HC-05 Bluetooth Module. My LED is connected to Pin 9 of the Arduino I/O. TX and RX of HC-05 is connected to Pins 1 and 0 of Arduino respectively. Here's the code I am using:

int output = 9;         //I will be using to control a DC motor(LED is just for testing).
int output2 = 10;
char final[4];
char correct[4] = {'Q','W','E','R'};
int pass_true;

void setup() {
  pinMode(output, OUTPUT);
  pinMode(output2, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  while(Serial.available()){
    for(int i=0; i&lt;4; i++){
      final[i] = Serial.read();
    }
    for(int i=0; i&lt;4; i++){
      if(final[i]==correct[i]){
        pass_true = 1;
      }
      else{
    pass_true = 0;
    break;
      }
    }
  }

  if(pass_true==1){
    digitalWrite(output, HIGH);
    Serial.println("ON");
    delay(3000);
    pass_true = 0;
  }
  else{
    digitalWrite(output, LOW);
  }

}


I am using Bluetooth SPP Pro Android App to send the 4-byte pass code ("QWER")

The problem is the LED wont light up. I tried replacing the LED thinking that it may be a dead one but it's not. The "TX" LED on the board blinks everytime I press "SEND" in the Bluetooth App, but still Pin 9 doesn't seem to produce the HIGH output at all. Is there a problem with the code?
Try using the following code you need to use String and concatenate that

    String rcev_data="";
bool chk=false;
\#define output 9

\#define output2 10

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(output, OUTPUT);
  pinMode(output2, OUTPUT);
}

void loop() 
{
  // put your main code here, to run repeatedly:
  while(Serial.available())
  {
    char rxx = Serial.read();
    recv.concat(rxx);
    delay(10);
    if (recv == "QWER")
    {
       chk=1;
       break;
     }
    else
     chk=0;
 }



  if (chk)
  {
    digitalWrite(output,HIGH);
    Serial.println("ON");
    delay(3000);
    chk=0;
  }

  else
  {
    digitalWrite(output,LOW);
  }
  recv="";
}