bluetooth controlled door lock

#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX. 
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
// 
 
char c[5],s[5];
int i,a=1;
 
void setup() 
{
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
    Serial.begin(9600);
    Serial.println("Arduino is ready");
 
    // HC-05 default serial speed for commincation mode is 9600
    BTserial.begin(9600);  
}
 
void loop()
{
    digitalWrite(13,LOW);
    // Keep reading from HC-05 and send to Arduino Serial Monitor
    if (BTserial.available()>0)
    {  
      for(i=0;i<4;i++){
        c[i] = BTserial.read();
        delay(100);
        Serial.print(c[i]);
        s[i]=c[i];
      }
      s[i]='\0'; //store data in different array
      Serial.println("");
    }
      if((c[0]==1){ //trying to make this set of statements to work
       
         Serial.println("available");
         Serial.println("UNLOCKED");
           
      }
      else{
           Serial.println("NOOOOOOOO");
           Serial.println("TRY AGAIN");
           delay(2000);
     }
 
   // Keep reading from Arduino Serial Monitor and send to HC-05
 if (Serial.available())
    {
        c[0] =  Serial.read();
        BTserial.write(c[0]);  
    }
}

i receive the data from bluetooth and i have checked that the values are stored as it should be but it doesnt print UNLOCKED even when the condition is true so please help me with it

May be you meant

if((c[0]=='1') // the character '1' not the Value 1??

Not sure why your read 4 data though (which might not even be there)? Code feels weird - better check the serial tutorial

i am still a beginner so i dont know much about it , if you may give me some tips on how to do it more efficiently it would help me a lot and thank you for your reply :)

Hello,

If you are new to programming, remember rule 1. "The Computer is always right!" It will do EXACTLY what you say.

If you have a Feeling that it doesn't do something even though the condition is met, you are probably wrong. To check, use something like Serial.print(c[0]) instead of the "NOOOOO" Statement. That will provide you with enough Information to figure out the difference between what you thought you programmed and what you really programmed.

BTW, Keep in mind that while the mathematical value of 1 is 1, the value of the ASCII character "1" is 49. That is what J-M-L is suggesting you check for.

Read the posts that are always floating at the top of this forum - you will learn a lot