HELP ABOUT ARDUINO

Im trying to create a project the one I found in unstructables but i dont have the arduino duemilanove i only have arduino uno do i need to create another program or is it the same....

here is the program

int lock = 9;          //pin 9 on Arduino
char final[4];         //Characters the Arduino will receive
char correct[4] = {'A','B','C','D'};    //User-Defined Password
int pass_correct = 0;          //Does Password match, 0=false 1=true

void setup()
{
pinMode(lock, OUTPUT);
Serial.begin(9600);
digitalWrite(lock, HIGH);  //By default, lock is active(locked)
}

void loop()
{
while(Serial.available()) 
{
  for(int i=0; i<4; i++)   //While data is available read 4 bytes
  {
   final[i] = Serial.read();  //Read 4 bytes into the array labled "final"
  }

  for(int i=0; i<4; i++)
  {
   if(final[i]==correct[i]) //Compare each char received to each car in our password in order
   {
    pass_correct = 1;   //If we compare two chars and they match, set the pass_correct variable to true(1)
   }
   else
   {
    pass_correct = 0;  //if the two compared chars do NOT match, set pass_correct variable to false(0)
    break;   //End loop and stop comparing chars
   }
  }
}

if(pass_correct==1)  //If all chars compared match, deactivate(unlock) the lock for 5 seconds
{
  Serial.println("Unlocked");
  digitalWrite(lock, LOW);
  delay(5000);
  digitalWrite(lock, HIGH); 
  Serial.println("Locked");
  pass_correct = 0;
}
else
{
digitalWrite(lock, HIGH); //Else if there was not a complete match, keep the lock high(locked)
}

/* 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);


}

I don't see anything in the code that would prevent it from running on an Uno. It would help to use autoformat in the IDE (control t) before posting code IN CODE TAGS. Makes it more readable and we can cut and paste into our IDE to test the code.

do i need to create another program or is it the same....

Have you tried that (improperly posted) code? What happened? What did you expect?

The two boards ar practically the same..
There are errors in you code.. some pointed out , but there are still errers !
If the object is to wait for sequence ABCD, this can be solved simplar than this

:int lock = 9;          //pin 9 on Arduino
char final[4];         //Characters the Arduino will receive
char correct[4] = {'A','B','C','D'};    //User-Defined Password
int pass_correct = 0;          //Does Password match, 0=false 1=true

void setup()
{
pinMode(lock, OUTPUT);
Serial.begin(9600);
digitalWrite(lock, HIGH);  //By default, lock is active(locked)
}

void loop()
{
while(Serial.available())
{
  for(int i=0; i<4; i++)   //While data is available read 4 bytes
  {
   final[color=red][i][/color] = Serial.read();  //Read 4 bytes into the array labled "final"
  }
 //NEW
[color=red]  pass_correct = 1[/color]
  for(int i=0; i<4; i++)
  {
   if(final[i]<>correct[i])   pass_correct = 0;   //If we compare two chars and they match, set the pass_correct variable to true(1)
   }
  }
}

if(pass_correct==1)  //If all chars compared match, deactivate(unlock) the lock for 5 seconds
{
  Serial.println("Unlocked");
  digitalWrite(lock, LOW);
  delay(5000);
  digitalWrite(lock, HIGH);
  Serial.println("Locked");
  pass_correct = 0;
}
else
{
digitalWrite(lock, HIGH); //Else if there was not a complete match, keep the lock high(locked)
}

/* 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);


}

.

I tried it but the lock wont open so i guess there must be something wrong with the program or the connection

can this help you ?
http://playground.arduino.cc/Code/Password

i tried the code but when i open the bluetooth app i cant send the command to open it and if i do the lock is still locked

i open the bluetooth app i cant send the command to open it and if i do the lock is still locked

If you can't send the command, the problem isn't on the Arduino end.

Can you suggest a bluetooth app that i can use to send commands i tried many apps but they dont work

knut_ny:
The two boards ar practically the same..
There are errors in you code.. some pointed out , but there are still errers !
If the object is to wait for sequence ABCD, this can be solved simplar than this

:int lock = 9;          //pin 9 on Arduino

char final[4];         //Characters the Arduino will receive
char correct[4] = {'A','B','C','D'};    //User-Defined Password
int pass_correct = 0;          //Does Password match, 0=false 1=true

void setup()
{
pinMode(lock, OUTPUT);
Serial.begin(9600);
digitalWrite(lock, HIGH);  //By default, lock is active(locked)
}

void loop()
{
while(Serial.available())
{
  for(int i=0; i<4; i++)   //While data is available read 4 bytes
  {
   final[i] = Serial.read();  //Read 4 bytes into the array labled "final"
  }
//NEW
  pass_correct = 1
  for(int i=0; i<4; i++)
  {
   if(final[i]<>correct[i])   pass_correct = 0;   //If we compare two chars and they match, set the pass_correct variable to true(1)
   }
  }
}

if(pass_correct==1)  //If all chars compared match, deactivate(unlock) the lock for 5 seconds
{
  Serial.println("Unlocked");
  digitalWrite(lock, LOW);
  delay(5000);
  digitalWrite(lock, HIGH);
  Serial.println("Locked");
  pass_correct = 0;
}
else
{
digitalWrite(lock, HIGH); //Else if there was not a complete match, keep the lock high(locked)
}

/* 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);

}




i tried this one but it has errors
.

Can you suggest a bluetooth app that i can use to send commands i tried many apps but they dont work

No. I can recommend that you take a big sledge hammer to your bluetooth device. Or, at least put it away until you learn to send data over wires.

As I said I'm trying to build a bluetooth door lock and bluetooth is wireless

As I said I'm trying to build a bluetooth door lock and bluetooth is wireless

Either you start with building a door lock and you then make it wireless, or you get the wireless part working, then add a door lock.

Which are you doing? If "blindly following an instructables" is your answer, then you should be posting on the instructables forum.

code works - sort of.

code works - sort of.

That's like being a little bit pregnant. Either it works or it doesn't. There is no "sort of" about it.