Keypad 3X4 values (SOLVED)

if(key)

Morgan already asked what you think this does. Put into English, it means "If 'key' is larger than 0".
Beginning to see the problem?

And as already asked by both PaulS and aarg now, why two opening curly brackets here? :-

if(key){{

And as already asked by both PaulS and aarg now, why two opening curly brackets here? :-

Ya, I see the problem, and for the record, I did fix the {{, so sorry about that.

Just curious, but is there a particular reason if(key) does this?
Also, is there a way to get around this?

JTMMcBroom:
Just curious, but is there a particular reason if(key) does this?

Usually, it always returns a value larger than 0.

Also, is there a way to get around this?

Maybe you could make it a different value in the array, then subtract that value after the keypress:-

char keys[ROWS][COLS] =
{
  {1,2,3},
  {4,5,6},
  {7,8,9},
  {'#',10,'*'}
};
.
.
.
if(key)
{
    if(key==10)
        key=0;
    // Other stuff here
}

But if you do that, a zero still won't be handled properly by the rest of your code. I think you're probably still better off working with chars '0', '1', '2', '3', etc and building a char array rather than 0, 1, 2, 3, then converting afterwards.

OK, besides obviously fixing the array, how could I go about fixing that.
(Turning the Char back into numbers, I mean).

What does if(key) do about non-numeric inputs? the # and the *? for my project, it turned on the led permanently, but what does the code actually say for it to do?

Thanks for sticking with me and helping.

I tried something similar to what you said the first time, and I think It works with just numbers in the matrix.

const int start = 2;
const int ledpin = 13;
const int motorcontrol = 4;
int count = 0;
int tens = 10;
int ones = 1;
float tenths = .1;
float hundredths = .01;
float Time = 0;
int buttonstate = digitalRead(start);
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {2, 3, 4},
  {5, 6, 7},
  {8, 9, 10},
  {'#', 1, '*'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 12, 11, 10 };
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );



void setup() {
  pinMode(ledpin, OUTPUT);
  pinMode(start, INPUT);
  Serial.begin(9600);
}

void loop() {
  buttonstate = digitalRead(start);
  if (count < 4) {
    char key = kpd.waitForKey();
    if (key) {
      { // Check for a valid key.

        digitalWrite(ledpin, HIGH);
        delay(1000);
        digitalWrite(ledpin, LOW);

        count = count + 1;
      }
      if (count == 1) {
        tens = tens * key - 10 ;
      }
      if (count == 2) {
        ones = ones * key - 1 ;
      }
      if (count == 3) {
        tenths = tenths * key - .1 ;
      }
      if (count == 4) {
        hundredths = hundredths * key -.01;


      }
    }
    Time = tens + ones + tenths + hundredths ;
  }

  if (buttonstate == HIGH && count < 5) {
    digitalWrite(ledpin, HIGH);
    delay(1000 * Time);

  }
  else {
    digitalWrite(ledpin, LOW);
  }
}

What I changed was I subtracted 1 unit of the measurement from each variable when the variable was being redefined. Thank you Soooo much.