Pin13 output problem?

I have coded the following in the context of controlling how long a small electric car runs.

const int start = 2;
const int ledpin = 13;
const int motorcontrol = 4;
int count = 0;
int tens = 10;
int ones = 1;
int tenths = .1;
int hundredths = .01;
int 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] = {
  {1,2,3},
  {4,5,6},
  {7,8,9},
  {'#',0,'*'}
};
// 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.
  
    switch (key){
    default :
    digitalWrite(ledpin, HIGH);
    delay(1000*key);
    digitalWrite(ledpin, LOW);
    
    count = count + 1;
    }
    if (count == 1) {
    tens = tens*key ;}
    if (count == 2) {
    ones = ones*key ;}
    if (count == 3) {
    tenths = tenths*key ;}
    if (count == 4){
    hundredths = hundredths*key;
    }
    }
  Time = tens + ones + tenths + hundredths ; }
  else {
    digitalWrite(ledpin, LOW);}
  if (buttonstate == HIGH && count < 5) {
    digitalWrite(ledpin, HIGH);
    delay(1000*Time);
    
  }
  else {
    digitalWrite(ledpin, LOW);
  }
    }

Pin 13 is the output, and it should be outputing for time Time*1000, but it's not outputing anything when the buttonstate is high. It is also accepting 5 numbers to add, as opposed to the 4 I thought it would. Where did I go Wrong?

int tenths = .1;
int hundredths = .01;

Please look up the definition of an integer.

You really have to learn how to not use delay().
Read Robin2 's discussion.
http://forum.arduino.cc/index.php?topic=223286.0

You don't seem to know what the switch statement is for.

This is code you grabbed and hacked isn't it?
That in itself is Fine as long as you're willing to look up every bit you don't understand.

Do you know where the Arduino site Reference page is? That might help you a LOT. I open up a browser along with my IDE and keep tabs with all the pages I need to refer to right there. If I am the LEAST BIT foggy on a command, I look it up. There's so many and they all have to be right.

A couple more things;
1), are the numbers on the keypad still valid, even without the ' '? Because I need numbers to calculate with, I thought it would take out a little code to not start them off as strings. The thing is, every example I found has them 'number' instead of just the number. It didn't draw any errors, in case you were wondering.

  1. This stuff still does not explain why I get 5 numbers, where is the fifth number going?

  2. when you talk about the tenths and the hundredths, is it similar to python, where those are represented by another class, i think it's "float" on python.

  if(key){  // Check for a valid key.
 
    switch (key){
    default :

A switch statement with one case looks pretty silly, especially when that case is not exclusionary. It reduces to:

   if(key)
   {
      if(key)
      {

LarryD:
int tenths = .1;
int hundredths = .01;

Just curious now, but why wouldn"t this return an error?

JTMMcBroom:
Just curious now, but why wouldn"t this return an error?

Because assigning zero to an integer isn't an error.