title: arduino keypad how to get more than one string
body: <p>i have been trying to read more than one string from arduino keypad but it seems the first string is always appended to the second one and i dont know why? When i print studentNumber, the access code plus the asterisks are appended to the studentNumber, what could be causing this? please help, thanks a lot.</p>
  
  <pre><code>#include &lt;Keypad.h&gt;
  #include &lt;LiquidCrystal.h&gt;
  #include &lt;Servo.h&gt;
  
  const byte ROWS = 4; //four rows
  const byte COLS = 3; //three columns
  char keys[ROWS][COLS] = {
      {'1','2','3'},
      {'4','5','6'},
      {'7','8','9'},
      {'*','0','#'}
  };
  
  byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the keypad
  byte colPins[COLS] = {13, 12, 11}; //connect to the column pinouts of the keypad
  
  // initialize the library with the numbers of the interface pins
  LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
  Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  char holdKeys[] = {};
  int i = 0;
  int j = 0;
  char accessCode[5];
  char holdMaskedCode[5];
  char holdMaskedNumber[8];
  char studentNumber[9];
  String accessCodeString;
  Servo servo;
  
  
  void setup() {
    // put your setup code here, to run once:
  
    servo.attach(5);
    lcd.begin(16, 4);
    lcd.setCursor(0,0);
    lcd.print("Welcome");
    lcd.setCursor(0,0);
    pinMode(4, OUTPUT);
    delay(2000);
  
   lcd.clear();
   lcd.print("Access Code");
    //keypad.addEventListener(getAccessCode);
  
  }
  
  void loop()
  {
    char key = keypad.getKey();
    if(key)
    {   
      if(i &lt; 5)
      {
        accessCode[i] = key;
        holdMaskedCode[i] = '*';
        lcd.setCursor(1,2);
        lcd.print(String(holdMaskedCode));
        if(i == 4)
        {
          lcd.clear();
          lcd.setCursor(1,2);
          accessCodeString = String(accessCode);
          lcd.clear();
          lcd.print("Student Number");
        }
  
        i++;
      }
      else
      {
        if(j &lt; 9)
        {
          studentNumber[j] = key;
          holdMaskedNumber[j] = '*';
          lcd.setCursor(0,2);
          lcd.print(holdMaskedNumber);
  
          if(j == 8)
          {
            lcd.clear();
            String number = String(studentNumber);
            lcd.print(number);
  
            delay(1000);
            lcd.clear();
            for(int i =0; i&lt;10; i++)
            {
              lcd.print("Please wait.");
              delay(500);
              lcd.clear();
              lcd.print("Please wait..");
              delay(500);
              lcd.clear();
              lcd.print("Please wait...");
              delay(500);
              lcd.clear();
            }
            digitalWrite(4, HIGH);
            for(int k =0; k&lt;=180; k+=2)
            {   
              servo.write(k);
              delay(15);
            }
            setup();
  
          }
  
          j++;
        }
  
      }
  
    }
  
  }
  </code></pre>