user34312: I am trying to build a calculator with an Arduino, an LCD display, and a keypad. Getting inputs from the keypad is not the issue. Before I can add, subtract, multiply, or divide any two numbers, I want to make sure the calculator registered the given number. I am trying to program it (so far) so that I type in a number and press enter (the @ sign I assigned to my keypad) and the LCD prints out that number. As you will see, I attempted to devise a logic mechanism for the Arduino to recognize the typed number. 
I thought since as you type more numbers the value of the first number typed increases by 10 fold each time (if you start by pressing 4 then if you press another number such as 5 following it, that 4 will become 40, and 400 if another number is pressed, etc...) I could multiply that number (and every following number) by 10, 100, 100, etc...
But it doesn't work and I need help so that the number can be collected by the Arduino.
Here's my attempt at it:
    #include <LiquidCrystal.h>
    #include "Arduino.h"
    #include "Keypad.h"

    int count = 0;
    int row = 0;
    int column = 0;

    //const int buzzer = 0;

    int value1;
    int value2 = 0;

    int spot1 = 0;
    int spot2 = 0;
    int spot3 = 0;
    int spot4 = 0;
    int spot5 = 0;
    int spot6 = 0;
    int spot7 = 0;
    int spot8 = 0;

    LiquidCrystal lcd(1, 2, 3, 4, 5, 6 );

    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
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS 
    );

    void setup() {
      //pinMode(buzzer, OUTPUT);
      lcd.begin(16,2);
      lcd.print("---Calculator---");
      delay(2000);
      lcd.clear();
      lcd.print("Value1: ");
      lcd.blink();

    }

    void loop() {
char key = keypad.getKey();

if(key != NO_KEY){
  lcd.print(key);
  if(key != '%' && key != '@'){
    count++;
  }
  else if(count == 1){
    spot1 = key;
  }
  else if(count == 2){
    spot2 = key;
  }
  else if(count == 3){
    spot3 = key;
  }
  else if(count == 4){
    spot4 = key;
  }
  else if(count == 5){
    spot5=key;
  }
  else if(count == 6){
    spot6=key;
  }
  else if(count == 7){
    spot7=key;
  }
  else if(count == 8){
    spot8=key;
  }

  if(key=='@'){
    if(count == 1){
      value1 = spot1;
    }
    else if(count == 2){
      value1 = (spot1*10)+(spot2);
    }
    else if(count == 3){
      value1 = (spot1*100)+(spot2*10)+spot3;
    }
    if(count == 4){
      value1 = (spot1*1000)+(spot2*100)+(spot3*10)+spot4;
    }
    if(count == 5){
      value1 = (spot1*10000)+(spot2*1000)+(spot3*100)+(spot4*10)+spot5;
    }
    if(count == 6){
      value1 = (spot1*100000)+(spot2*10000)+(spot3*1000)+(spot4*100)+(spot5*10)+spot6;
    }
    if(count == 7){
    }
    if(count == 8){
    }
    lcd.print(value1);
  }












  if(key  == '%'){
    count = 0;
    lcd.clear();
    lcd.print("Value1: ");
    lcd.blink();
  }
}

}

PS: If you know any better way to accomplish this goal, I would love to hear it.

user33871: if(key != '%' && key != '@'){
  count++;
}
else if(count == 1){
  spot1 = key;
}
else if(count == 2){
  spot2 = key;
}

You've got a problem here.  If key isn't '%' and isn't '@' then you increase count but since all the rest are else if to that then it skips over all of them and never actually puts the digit int the spot.  

user3917: If your keypad setup results in '%' and '@' arriving correctly, then it probably also results in the characters '0', '1', ... '9' arriving when number keys are pressed, rather than digit values 0, 1, ... 9 arriving.
Be that as it may, there's a far simpler approach to building value1 which does not use a big set of spot values like your method does.  Here is an illustration of it.
// ... Before number input, zero out a number-accumulator variable
long int nin = 0;

do {
  key = keypad.getKey();
  if (key != NO_KEY) {
    lcd.print(key);
    // As number keys are pressed, add them to tail of number
    if (key >= '0' && '9' >= key) {
      nin = 10*nin + (key & 0xF);   // Get low 4 bits of key
    }
  }
  if (key == '@') {
    lcd.print("Value = ");
    lcd.print(nin);
    // ... do whatever else with value
    // ... then get ready for next value
    nin = 0;
  }
} while (1);


34312: <p>I am trying to build a calculator with an Arduino, an LCD display, and a keypad. Getting inputs from the keypad is not the issue. Before I can add, subtract, multiply, or divide any two numbers, I want to make sure the calculator registered the given number. I am trying to program it (so far) so that I type in a number and press enter (the @ sign I assigned to my keypad) and the LCD prints out that number. As you will see, I attempted to devise a logic mechanism for the Arduino to recognize the typed number. </p>

<p>I thought since as you type more numbers the value of the first number typed increases by 10 fold each time (if you start by pressing 4 then if you press another number such as 5 following it, that 4 will become 40, and 400 if another number is pressed, etc...) I could multiply that number (and every following number) by 10, 100, 100, etc...</p>

<p>But it doesn't work and I need help so that the number can be collected by the Arduino.</p>

<p>Here's my attempt at it:</p>

<pre><code>    #include &lt;LiquidCrystal.h&gt;
    #include "Arduino.h"
    #include "Keypad.h"

    int count = 0;
    int row = 0;
    int column = 0;

    //const int buzzer = 0;

    int value1;
    int value2 = 0;

    int spot1 = 0;
    int spot2 = 0;
    int spot3 = 0;
    int spot4 = 0;
    int spot5 = 0;
    int spot6 = 0;
    int spot7 = 0;
    int spot8 = 0;

    LiquidCrystal lcd(1, 2, 3, 4, 5, 6 );

    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
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS 
    );

    void setup() {
      //pinMode(buzzer, OUTPUT);
      lcd.begin(16,2);
      lcd.print("---Calculator---");
      delay(2000);
      lcd.clear();
      lcd.print("Value1: ");
      lcd.blink();

    }

    void loop() {
char key = keypad.getKey();

if(key != NO_KEY){
  lcd.print(key);
  if(key != '%' &amp;&amp; key != '@'){
    count++;
  }
  else if(count == 1){
    spot1 = key;
  }
  else if(count == 2){
    spot2 = key;
  }
  else if(count == 3){
    spot3 = key;
  }
  else if(count == 4){
    spot4 = key;
  }
  else if(count == 5){
    spot5=key;
  }
  else if(count == 6){
    spot6=key;
  }
  else if(count == 7){
    spot7=key;
  }
  else if(count == 8){
    spot8=key;
  }

  if(key=='@'){
    if(count == 1){
      value1 = spot1;
    }
    else if(count == 2){
      value1 = (spot1*10)+(spot2);
    }
    else if(count == 3){
      value1 = (spot1*100)+(spot2*10)+spot3;
    }
    if(count == 4){
      value1 = (spot1*1000)+(spot2*100)+(spot3*10)+spot4;
    }
    if(count == 5){
      value1 = (spot1*10000)+(spot2*1000)+(spot3*100)+(spot4*10)+spot5;
    }
    if(count == 6){
      value1 = (spot1*100000)+(spot2*10000)+(spot3*1000)+(spot4*100)+(spot5*10)+spot6;
    }
    if(count == 7){
    }
    if(count == 8){
    }
    lcd.print(value1);
  }












  if(key  == '%'){
    count = 0;
    lcd.clear();
    lcd.print("Value1: ");
    lcd.blink();
  }
}

}
</code></pre>

<p>PS: If you know any better way to accomplish this goal, I would love to hear it.</p>
 33871: <pre><code>if(key != '%' &amp;&amp; key != '@'){
  count++;
}
else if(count == 1){
  spot1 = key;
}
else if(count == 2){
  spot2 = key;
}
</code></pre>

<p>You've got a problem here.  If key isn't '%' and isn't '@' then you increase count but since all the rest are else if to that then it skips over all of them and never actually puts the digit int the spot.  </p>
 3917: <p>If your keypad setup results in '%' and '@' arriving correctly, then it probably also results in the characters '0', '1', ... '9' arriving when number keys are pressed, rather than digit values 0, 1, ... 9 arriving.</p>

<p>Be that as it may, there's a far simpler approach to building <code>value1</code> which does not use a big set of spot values like your method does.  Here is an illustration of it.</p>

<pre><code>// ... Before number input, zero out a number-accumulator variable
long int nin = 0;

do {
  key = keypad.getKey();
  if (key != NO_KEY) {
    lcd.print(key);
    // As number keys are pressed, add them to tail of number
    if (key &gt;= '0' &amp;&amp; '9' &gt;= key) {
      nin = 10*nin + (key &amp; 0xF);   // Get low 4 bits of key
    }
  }
  if (key == '@') {
    lcd.print("Value = ");
    lcd.print(nin);
    // ... do whatever else with value
    // ... then get ready for next value
    nin = 0;
  }
} while (1);
</code></pre>
