run a component for a set time

hi, i have a keypad and a component i want to run the component for whatever time is inputted (1-60 mins preferably) then press # to execute it. i cant seam to get this to work, can someone help me out please.

i cant seam to get this to work

Show us your work so we an help you.

Please, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.

Put your sketch between the code tags [code][/code]

Please show us a schematic of your circuit.

.

this is what i have so far:

#include <Keypad.h>
#include <LiquidCrystal.h>

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] = {
  11, 12, 2, 3}; //PINS WHERE THE ROWS OF THE KEYPAD IS CONNECTED
byte colPins[COLS] = {
  4, 5, 6};  //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte ledPin = 13; 
byte currentState = 1;        //MAKE VARIABLE CURRENTSTATE, SET IT TO START IN STATE 1 IN AUTOMODE


//LCD DISPLAY SETUP
LiquidCrystal lcd(19, 18, 7, 8, 9, 10);  //PINS WHERE THE LCD DISPLAY IS CONNECTED

unsigned long dlyTime = 0;

void setup(){
  Serial.begin(9600);
  lcd.begin(16, 2);   // SETTING UP LCD'S NUMBER OF COLUMNS AND ROWS
}

void loop(){
  char key = keypad.getKey();
  lcd.setCursor(0, 0);
  lcd.print ("Set delay time:");
  delay (50);
  lcd.setCursor(0, 1);
  lcd.print ("_____ seconds");

  if (dlyTime == 0);
  {
    enterDelay();
  }
}

void enterDelay(void){
 
   
   
  char key = keypad.getKey();
  switch (currentState)
  {

    //***************************
  case 1:
 //Serial.println("case1");
    lcd.setCursor(0, 1);
    if (key) 
    {
      
      lcd.print(key);
      lcd.setCursor(1, 1);
      lcd.print("____");
      currentState = 2;
    }

    else {
      currentState = 1;
    }


    break;
    //***************************
  case 2:

    lcd.setCursor(1, 1);
    if (key) 
    {
      lcd.print(key);
      currentState = 3;
    }
    else {
      currentState = 2;
    }
    break;
    //***************************
  case 3:

    lcd.setCursor(2, 1);
    if (key) 
    {
      lcd.print(key);
      currentState = 4;
    }
    else {
      currentState = 3;
    }
    break;
    //***************************
  case 4:

    lcd.setCursor(3, 1);
    if (key) 
    {
      lcd.print(key);
      currentState = 5;
    }
    else {
      currentState = 4;
    }
    break;
    //***************************
  case 5:

    lcd.setCursor(4, 1);
    if (key) 
    {
      lcd.print(key);
      currentState = 5;
    }
    else {
      currentState = 5;
    }
    break;
    //***************************
  default:
    currentState = 1;              //Back to state 1
  } // END SWITCH/CASE===========================================================
}

My reply got eaten after i hit post so if it shows up twice I do apologize.

It looks like you aren't updating dlyTime after you initialize it to zero - so that test to see if you should run the enterDelay() function will always be true and will always run every time through the loop. We're you going to be comparing it to an increasing millisecond counter?

I noticed too that you have delay(50) right after an lcd.print saying "set delay Time". You may be aware, but I wanted to point out (since it's too much of a coincidence) that delay(50) just stops the code from advancing for 50 ms and has nothing to do with dlyTime.

You can simplify this:-

case 5:
    lcd.setCursor(4, 1);
    if (key)
    {
        lcd.print(key);
        currentState = 5;
    }
    else
    {
        currentState = 5;
    }
    break;

The 'switch' statement is switching depending on the 'currentState' variable.
So if 'currentState' is equal to 5, you set it to 5 again, both if 'key' is larger than 0, or if 'key' is not larger than 0.
In effect, all that this actually does is:-

case 5:
    lcd.setCursor(4, 1);
    if (key)
        lcd.print(key);
    break;