user33204: I've been working on project for children showing the codes used by atc transponder. I've used a keypad and a 16×2 display , where user types a 4 digit code and display shows condition related to the code
E.g. typing 7500 on keypad will show hijack on display
What has went wrong??
My code is ------
    #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);//RS,EN,D4,D5,D6,D7
#include <Keypad.h>//header for keypad commands enabling
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'#','0','*','D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 0, 1, 2, 3 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 4, 5, 6, 7 };
//  Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

char inputArray[4]; //array to gather user keypad presses
char Vfr[4] = {'1','2','0','0'}; //array to hold keypad password
char Gliders[4] = {'1','2','0','2'};
char Hijack[4] = {'7','5','0','0'};
char Comfail[4] = {'7','6','0','0'};
char Emerg[4] = {'7','7','0','0'};
char Mic[4] = {'7','7','7','7'};

int i = 0;
int state = 1;

void setup()
{
  for(int k=8;k<14;k++)
  {
    pinMode(k,OUTPUT);//pins 8-14 are enabled as output
  }
  lcd.begin(16, 2);//initializing LCD
}

void loop()
{
while (state = 1);
{
 lcd.setCursor(0, 0);

 char key = kpd.getKey();

 //if a key is presseds
   if(key)
     {

     inputArray[i] = key; //store entry into array
     i++;
     lcd.clear(); //print keypad character entry to serial port

     if (key=='C');
       {
         lcd.setCursor(0, 1);
         lcd.print("Reset");
         i=0; //reset i
       }

     if (i == 4) //if 4 presses have been made
       {
         {

         //match input array to password array

           if (inputArray[0] == Vfr[0] &&
           inputArray[1] == Vfr[1] &&
           inputArray[2] == Vfr[2] &&
           inputArray[3] == Vfr[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("VFR");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Gliders[0] &&
           inputArray[1] == Gliders[1] &&
           inputArray[2] == Gliders[2] &&
           inputArray[3] == Gliders[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("GLIDERS");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Hijack[0] &&
           inputArray[1] == Hijack[1] &&
           inputArray[2] == Hijack[2] &&
           inputArray[3] == Hijack[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("HIJACK");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Comfail[0] &&
           inputArray[1] == Comfail[1] &&
           inputArray[2] == Comfail[2] &&
           inputArray[3] == Comfail[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("COMMFAIL");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Emerg[0] &&
           inputArray[1] == Emerg[1] &&
           inputArray[2] == Emerg[2] &&
           inputArray[3] == Emerg[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("EMERGENCY!");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Emerg[0] &&
           inputArray[1] == Emerg[1] &&
           inputArray[2] == Emerg[2] &&
           inputArray[3] == Emerg[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("EMERGENCY!");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Mic[0] &&
           inputArray[1] == Mic[1] &&
           inputArray[2] == Mic[2] &&
           inputArray[3] == Mic[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("MILITARY IC");
              }
         }
       }   
}
lcd.print(key); 
}
}


user10394: while (state = 1);

This line is a loop that will go around forever so long as you can set the variable state to 1.  What you mean is:
while (state == 1)

You don't need semicolons at the end of conditionals, here is another:
 if (key=='C');

If you fix those two bugs, you'll get a lot further.

33204: <p>I've been working on project for children showing the codes used by atc transponder. I've used a keypad and a 16×2 display , where user types a 4 digit code and display shows condition related to the code
E.g. typing 7500 on keypad will show hijack on display</p>

<p>What has went wrong??</p>

<pre><code>My code is ------
    #include &lt;LiquidCrystal.h&gt;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);//RS,EN,D4,D5,D6,D7
#include &lt;Keypad.h&gt;//header for keypad commands enabling
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'#','0','*','D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 0, 1, 2, 3 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 4, 5, 6, 7 };
//  Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

char inputArray[4]; //array to gather user keypad presses
char Vfr[4] = {'1','2','0','0'}; //array to hold keypad password
char Gliders[4] = {'1','2','0','2'};
char Hijack[4] = {'7','5','0','0'};
char Comfail[4] = {'7','6','0','0'};
char Emerg[4] = {'7','7','0','0'};
char Mic[4] = {'7','7','7','7'};

int i = 0;
int state = 1;

void setup()
{
  for(int k=8;k&lt;14;k++)
  {
    pinMode(k,OUTPUT);//pins 8-14 are enabled as output
  }
  lcd.begin(16, 2);//initializing LCD
}

void loop()
{
while (state = 1);
{
 lcd.setCursor(0, 0);

 char key = kpd.getKey();

 //if a key is presseds
   if(key)
     {

     inputArray[i] = key; //store entry into array
     i++;
     lcd.clear(); //print keypad character entry to serial port

     if (key=='C');
       {
         lcd.setCursor(0, 1);
         lcd.print("Reset");
         i=0; //reset i
       }

     if (i == 4) //if 4 presses have been made
       {
         {

         //match input array to password array

           if (inputArray[0] == Vfr[0] &amp;&amp;
           inputArray[1] == Vfr[1] &amp;&amp;
           inputArray[2] == Vfr[2] &amp;&amp;
           inputArray[3] == Vfr[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("VFR");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Gliders[0] &amp;&amp;
           inputArray[1] == Gliders[1] &amp;&amp;
           inputArray[2] == Gliders[2] &amp;&amp;
           inputArray[3] == Gliders[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("GLIDERS");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Hijack[0] &amp;&amp;
           inputArray[1] == Hijack[1] &amp;&amp;
           inputArray[2] == Hijack[2] &amp;&amp;
           inputArray[3] == Hijack[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("HIJACK");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Comfail[0] &amp;&amp;
           inputArray[1] == Comfail[1] &amp;&amp;
           inputArray[2] == Comfail[2] &amp;&amp;
           inputArray[3] == Comfail[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("COMMFAIL");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Emerg[0] &amp;&amp;
           inputArray[1] == Emerg[1] &amp;&amp;
           inputArray[2] == Emerg[2] &amp;&amp;
           inputArray[3] == Emerg[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("EMERGENCY!");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Emerg[0] &amp;&amp;
           inputArray[1] == Emerg[1] &amp;&amp;
           inputArray[2] == Emerg[2] &amp;&amp;
           inputArray[3] == Emerg[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("EMERGENCY!");
              }
         }

         {

         //match input array to password array

           if (inputArray[0] == Mic[0] &amp;&amp;
           inputArray[1] == Mic[1] &amp;&amp;
           inputArray[2] == Mic[2] &amp;&amp;
           inputArray[3] == Mic[3])
              {
               lcd.setCursor(0, 1);
               lcd.print("MILITARY IC");
              }
         }
       }   
}
lcd.print(key); 
}
}
</code></pre>
 10394: <pre><code>while (state = 1);
</code></pre>

<p>This line is a loop that will go around forever so long as you can set the variable state to 1.  What you mean is:</p>

<pre><code>while (state == 1)
</code></pre>

<p>You don't need semicolons at the end of conditionals, here is another:</p>

<pre><code> if (key=='C');
</code></pre>

<p>If you fix those two bugs, you'll get a lot further.</p>
