problem with my project programm

hello everybody i'm a french people so excuse if i have got a bad English

my problem is that if i enter the right code it repeat infinitely "your welcome"
i try with if/else but doesn't work also and have the same problem
so guys if you can help me thanks you
marin

so first there his my code :

#include <SoftwareSerial.h>
SoftwareSerial RFID(4, 5);

#include "TM1650.h"
#include <Keypad.h>

char code [8] = {'2', '8', '1', '0', '1', '9', '9', '8'};
int data[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int acceptedtag [14] = {2, 48, 66, 48, 48, 57, 48, 54, 68, 69, 55, 49, 49, 3};
int key1 = 0;
boolean key2 = true;
char key;
boolean key3 = true;
int key4 = 0;

TM1650 keyPad(2, 3);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  RFID.begin(9600);
  keyPad.begin();
  Serial.println(F("ready"));
}

void loop() {
  if (key3 == true) {
    Serial.println(F("Si vous voulez utilisez votre rfid tag tapez A"));
    Serial.println(F("ou si vous voulez utilisez votre mot de passe tapez B"));
    key3 = false;

  }
  char key = keypadreader();
  if (key == 'A') {
    while ( key1 <= 14) {
      if (key2 == true) {
        Serial.println(F("passez votre tag rfid devant le lecteur rfid s'il vous plait."));
        key2 = false;
      }
      if (RFID.available() > 0)
      {

        data[key1] = RFID.read();

        if (data[key1] == acceptedtag[key1]) {
          key4++;
        }
        key1++;
      }
    }
  }
  if (key == 'B') {
    while (key1 <= 7) {
      if (key2 == true) {
        Serial.print(F("tapez votre code s'il vous plait: "));
        key2 = false;
      }
      key = keypadreader();
      if (key != NO_KEY) {
        Serial.print(key);
        if (key == code[key1]) {
          Serial.println(code[key1]);
          key4++;
          Serial.println(key4);

        }
        key1++;
        char key = 0;
        delay(500);
      }
    }

    //le reste ne fonctionne pas ?? ah si jusqu'au code aprés a vos risque et peril (0313) c'est bon tout fonctionne sauf le txt
    // "your welcome" qui s'affiche sans s'arrêtter (0815)


  }
  if ((key1 == 15) || (key1 == 8)) {
    switch (key4) {
      case 14: Serial.println(F("your welcome")); break;
      case 8: Serial.println(F("your welcome")); break;
      default : Serial.println(F("error")); break;
    }
  }
  int key1 = 0;
  boolean key2 = true;
  int key4 = 0;
  boolean key3 = true;
  int data[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

}
char keypadreader() {
  char key = 0;
  delay(500);
  keyPad.begin();

  switch (keyPad.readKey())
  {
    case 0x4c: key = '1'; break;
    case 0x4d: key = '4'; break;
    case 0x4e: key = '7'; break;
    case 0x4f: key = '*'; break;
    case 0x54: key = '2'; break;
    case 0x55: key = '5'; break;
    case 0x56: key = '8'; break;
    case 0x57: key = '0'; break;
    case 0x64: key = '3'; break;
    case 0x65: key = '6'; break;
    case 0x66: key = '9'; break;
    case 0x67: key = '#'; break;
    case 0x74: key = 'A'; break;
    case 0x75: key = 'B'; break;
    case 0x76: key = 'C'; break;
    case 0x77: key = 'D'; break;
    default: break;
  }

  return key;


}

Please use [ code ] tags. Edit your first post to add them around your code.

Please also use the auto-format option on the Arduino Tools menu (or whatever it's called in French) The indenting is all wrong and making it hard to understand what your program does.

there it is and thanks you for your advice i didn't know there where this option in the arduino tools menu ^^

It took me a little while to find it. Here is the code near the bottom of the loop where you attempt to set all the variables back to zero, indicating that it should start again from the top...  int key1 = 0;

This creates a new local variable with the same name as the global one. the global one is used up to this point in the loop(), so it is what's used again on the next iteration of loop(). The global one never gets reset back to zero.

Remove the "int" in front of this line. And the other lines below.

thanks a lot but did you know why i had to put an int after the list called "data" ? ^^

XxmarinxX:
thanks a lot but did you know why i had to put an int after the list called "data" ? ^^

This is because you can't initialize an array within the code in one go like this, outside declaration time. You need to do a for loop for each element or memset (because you want to set them all to zero it's easy)

At the moment at the end of your code, this

 int key1 = 0;
  boolean key2 = true;
  int key4 = 0;
  boolean key3 = true;
  int data[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

is just re-declaring local variables not modifying the global ones.

thanks ^^