Bluetooth Doorlock via Android phone

I cant seem to get this working, I have tested the bluetooth module and can connect and receive data from it but cant seem to transmit data to it? here is the code I am using

int lock = 9;
 char final[4];
 char correct[4] = {'A','B','C','D'};
 int pass_correct = 0; // Does Password match, 0=false 1=true
 
void setup()
 {
 pinMode(lock, OUTPUT);
 Serial.begin(9600);
 digitalWrite(lock, HIGH);
 }
 
void loop()
 {
 while(Serial.available())
 {
   for(int i=0; i<4; i++)
   {
    final[i] = Serial.read();
 
  }
   for(int i=0; i<4; i++)
   {
    if(final[i]==correct[i])
    {
     pass_correct = 1;
    }
    else
    {
     pass_correct = 0;
     break;
    }
   }
 }
 
if(pass_correct==1)
 {
   Serial.println("Unlocked");
   digitalWrite(lock, LOW);
   delay(5000);
   Serial.println("Locked");
   pass_correct = 0;
 }
 else
 {
 digitalWrite(lock, HIGH);
 }
 
/* FOR TESTING
 Serial.print(final[0]);Serial.print(final[1]);Serial.print(final[2]);Serial.print(final[3]);
 Serial.print(" | ");
 Serial.print(correct[0]);Serial.print(correct[1]);Serial.print(correct[2]);Serial.print(correct[3]);
 Serial.print(" ");
 Serial.print(pass_correct);
 Serial.println("");
 */
 delay(500);
 

}]
 while(Serial.available())
 {
   for(int i=0; i<4; i++)
   {
    final[i] = Serial.read();
 
  }

If there is at least one byte to read, read all 4 of them. Fail!

I have tested the bluetooth module

A quick ebay search would show that there is not “THE bluetooth module” but 400 bazillion bluetooth modules.

can connect and receive data from it but cant seem to transmit data to it?

If this is a question, only you can answer it.

And this helps me how??
I do not understand the code I did not write it, I am just trying to use it, but cant get it to work for me?

I do not understand the code I did not write it, I am just trying to use it

Not a good way to work, in my opinion, but there you go. It's ok to use other peoples code, but you really should try to understand it.

We can't tell exactly what you are doing wrong (apart from the serial reading issue that PaulS pointed out), because we don't know which of the many available bluetooth units you have.

I learn by using different codes and when they work I figure out why they work and what does what. I have absolutely no experience in programming and have started trying to learn about a week ago. The bluetooth module I have is simply refered to as HC-06 if that is of any use?

Day or two in the past, my own Samsung galaxy S2 continues to be closed. Next my buddy implies myself to look this web site and also My partner and i revealed my own phone. Therefore i advise one to move your website to fix your trouble swiftly.
You should check out there samsung unlocking