need a help about testing a password

i want to turn on/off a LED by a password without using a keypad
.. need just char[5],
i want to put the password of 4 character at the time and test if true, Led X high, else, Led X low
.....
......
this is an exemple of my own work .... but it dosent work correctly
.....
.....

char data = ' '; //Variable for storing received data
char cod[5]=("1234") ; //code to test (1234);
int v= 0; //counter
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);

}
void loop()
{
digitalWrite(8,HIGH); //alwayse on
for (int j=0; j<4; j++)
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data & store into data

Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n");

if (data==cod[j])
{
v++;

}

}
}
if (v==4)
{digitalWrite(10,HIGH);}

}
.... need a smart solution ...
please ...
thanks aloot

It doesn't work?
What does that mean?
Because you never reset v?
Because a for loop is not the right control structure here?

Couple things.

1.) Please ALWAYS wrap your code in [ code ] [ /code ] tags.. (use the </> icon if needed..)

2.) If you dont want to use a keyboard/keypad to enter in your 'password'... how do you plan on entering it? What event lets you interact with your project?

3.) Where is this serial data coming from that you are attempting to parse in the code above?

I think reading the serial basics thread would help you out:

http://forum.arduino.cc/index.php?topic=396450

meaning by dosent work correctly m ... it need 4 time giving the right code to turn on the LED 10
.. all what i need is how to turn on a led using a password (caracters,numbers,...)
...
the serial come from a bluetooth sumilation

I'm not clear on your are saying or asking??

Did you bother to look at the serial basic link I posted for you?
http://forum.arduino.cc/index.php?topic=396450

slight edit taken from example #2 there: (not tested at work, no IDE..etc)

// Example 2 - Receive with an end-marker

const byte numChars = 5;
char receivedChars[numChars];   // an array to store the received data
char targetPassword[] = "1234";
boolean newData = false;

void setup(){
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop(){
    recvWithEndMarker();
    showNewData();
}

void recvWithEndMarker(){
    static byte indexCounter = 0;
    char endMarker = '\n';
    char receivedCharater;
   
    while(Serial.available() > 0 && newData == false){
        receivedCharater = Serial.read();

        if(receivedCharater != endMarker){
            receivedChars[indexCounter] = receivedCharater;
            indexCounter++;
            if (indexCounter >= numChars){
                indexCounter = numChars - 1;
            }
        }else{
            receivedChars[indexCounter] = '\0'; // terminate the string
            indexCounter = 0;
            newData = true;
        }
    }
}

void showNewData(){
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
		blinkLED(receivedChars);
    }
}

void blinkLED(submittedPassword){
	if(strcmp(submittedPassword, targetPassword) == 0){
		//do whatever you want to blink the led
	}else{
		//no match turn on fail led
	}

}