Math error

hello, i'm programing timer, where i will insert quantity of minutes via 4x4 matrix keyboard
my part of code is there:

lcd.clear();
        lcd.print(inputArray[0]);
        lcd.print("x");
        lcd.print(inputArray[1]);
        delay(2000);
        minutes = inputArray[0] + inputArray[1];
        lcd.clear();
        lcd.print(inputArray[0]);
        lcd.print("+");
        lcd.print(inputArray[1]);
        lcd.print("=");
        lcd.print(minutes);

if i insert two numbers, like 4 and 5 it should be 9
but it will return number: 105, i don't know why, anyone knows? thanks

you need lcd.print(inputArray[0], DEC); to enforce the value to be printed as decimal...

'4' = char(52)
'5' = char(53);

52 + 53 = ....

if i understand, now i have this code:

lcd.clear();
        lcd.print(inputArray[0]);  // there it prints right number
        lcd.print("x");
        lcd.print(inputArray[1]); // there it prints right number
        delay(2000);        
        minutes2 = (inputArray[0], DEC);
        minutes3 = (inputArray[1], DEC);
        minutes = minutes2 + minutes3;
        lcd.clear();
        lcd.print(inputArray[0]); // there still prints right number
        lcd.print("+");
        lcd.print(inputArray[1]); // there still prints right number
        lcd.print("=");
        lcd.print(minutes, DEC); // but there is wrong number

but still don't works, it returns wrong number

 minutes2 = (inputArray[0], DEC);

Can you explain what you think this line does?

minutes2 = (inputArray[0], DEC);

inputArray[0] is temporary memory in my arduino, it saves number what i click on my 4x4 matrix keyboard.

full code in loop() function is:

case CAS:
     /*
     lcd.print("Set time of");
     lcd.setCursor(0,1);
     lcd.print("detonation");
     delay(1500);*/
     lcd.clear();
     lcd.print("Minutes:");
     {
     while (state = 1)
     {
       char key = kpd.getKey();

       if(key)
	{       
        digitalWrite(ledka, HIGH);
        delay(20);
        digitalWrite(ledka, LOW);
        inputArray[cas] = key;
        cas++;
        lcd.print(key); 
        lcd.setCursor(8,0);
        delay(1200);
        }
      if(cas == 2){
        {
        lcd.clear();
        lcd.print(inputArray[0]);
        lcd.print("x");
        lcd.print(inputArray[1]);
        delay(2000);        
        minutes2 = (inputArray[0], DEC);
        minutes3 = (inputArray[1], DEC);
        minutes = minutes2 + minutes3;
        lcd.clear();
        lcd.print(inputArray[0]);
        lcd.print("+");
        lcd.print(inputArray[1]);
        lcd.print("=");
        lcd.print(minutes, DEC);
        delay(3000);        
        bombstatus = ON;
        lcd.clear();
        lcd.print("Time of detonation");
        lcd.setCursor(0,1);
        lcd.print("was set");
        goto ready; // redirect to countdown with set minutes
           }
        break;

And the comma and DEC?

i just tried what i understood from reply #1

i just tried what i understood from reply #1

Then, you need to go back and re-read reply #1.

you need lcd.print(inputArray[0], DEC); to enforce the value to be printed as decimal...

i have... lcd.print(minutes, DEC);

print(nr); can be interpreted by the compiler as the printing of a char or as the printing of a integer.

The ,DEC flag forces print to print an integer as a string of numbers e.g. "10"

What is the datatype of the inputArray[] ?

lcd.print("detonation");

And what is this?

it's part of this code

lcd.print("Set time of"); //first row on LCD display
     lcd.setCursor(0,1); // set the cursor to second row on LCD
     lcd.print("detonation"); // second row on LCD, it continues to first row: so at all it will print: Set time of detonation in two rows

but the problem is this: when i put two functions to math it turns classic numbers (5 or 6 or 7 or 9 etc.) to decimal numbers like 5 is 53

i have...

Code:

lcd.print(minutes, DEC);

I thought it had already been determined that "minutes" was the sum of two ASCiI codes

firstly it was without DEC, but it showed same as with DEC

I don't see that it would make a difference - read reply #1

sorry, i don't have idea what i should do in code, i'm newbie in programming

          goto ready;

goto - http://arduino.cc/hu/Tutorial/HomePage - Arduino - Home -

Think you have to learn some basics first before finalizing your project as I see the remarks made to help you are not yet inderstood by you.

So the best thing to do right now is to go through the tutorial section and refernce section to understand something about array's integers and chars etc.

my 2 cents.

problem is solved, now the part of code is:

minutes3 = inputArray[0] - 48;
        minutes2 = inputArray[1] - 48;
        minutes = minutes3 * minutes2;
 minutes2 = inputArray[1] - '0';