how do i give user time to respond before I check the input?

I need to get an input value high/low when the user pushes the button.
I want to give the user at least 2 seconds time to push the button. I tried the following but it does not work. Any suggestions?

long currentMillis = 0;
long previousMillis = 0;

for (currentMillis = millis(); (currentMillis - previousMillis) > 2000; previousMillis = currentMillis)
    {   
if {
       // statement to check if it is high
   }
else{
//do this if it is low
      }
}

Explain what you think that for loop is doing/going to accomplish.

And when you've explained that, try explaining why you think cross-posting is such a good idea.

to AWOL

It was an accident

To PaulS

currentMillis = millis() - assigns current time to currentMills
currentMillis - previousMillis)> 2000 - for loop checks for 2 seconds
previousMillis = currentMillis - assign new time to previousMills

The for statement says "Start with assigning currentMillis the value returned by millis(). Then, while currentMillis minus previousMillis is greater than 2000, do some stuff. Then, assign previousMillis the value in currentMillis".

So, on the first pass, currentMillis - previousMillis will have some value based on how long the Arduino has been running. That may, or may not, be greater than 2000, so the body may, or may not be executed. Regardless of whether or not it is, previousMillis will be set to currentMillis.

Then, the while clause is evaluated again. Since previousMillis is equal to currentMillis, the difference is 0. Since 0 is not greater than 2000, the for statement ends.

I can't see how that will wait for two seconds.

unsigned long start = millis();
while(millis() - start <= 2000)
{
    // Check for user input
    // If present
       break;
}

// You will get here as soon as the user input arrived or after waiting for 2 seconds.
// You'll need to do something in the body of the if statement to distinguish the
// two cases.

Thanks a lot for your reply.
However, I may need some more options.
I am testing switches. So not only that I need ANY input, but I have two cases when switch is passing or failing. When switch is passing, I get 5V at the pinSW, otherwise 0V. I need to display both cases.
I tried this, but it didn't work:

 unsigned long start = millis();
 while(millis() - start <= 2000)
      {  
        if((digitalRead(pinSW)= HIGH)
        {
      LCD.printf("switch %d PASSED", SW);
      delay(1000);
        }
        else
        {
       LCD.printf("switch %d FAILED", SW);
       delay(1000);
       }
      break;
    }

Also, do I need start = millis(); before the end of the while loop.

  if((digitalRead(pinSW)= HIGH)

I'd be really surprised if that compiles.

        if((digitalRead(pinSW)= HIGH)

Code that won't even compile can NOT be said to work or not work.

You can NOT assign a value to a function call. = != ==.

Also, do I need start = millis(); before the end of the while loop.

Only if you want to create an infinite loop. Stop two seconds from now. No, from now. No, from now. No, from now. Well, you get the point. I hope.

I just gave an example, my code is actually more complicated. When I said that it did not work, it was not because of the compiling (typing) errors but because it doesn't check the input for 2sec. I am new at this forum and I did not think that it would be an English type of class checking for spelling and grammar, rather elective class focusing on the functionality. Sorry, I will be more careful in future.

Let me be more careful and specific this time:
The only passing combination is under "if" statement bellow. Any other combination of pinSW_COL_1,2 and 3 is a fail.
Can you please tell me how to check within 2 sec if this is pass. My code here is displaying pass result, however, timing is still not working, I still have to press and hold the switch.

unsigned long start = millis();
      while(millis() - start <= 2000)
      {  
        if((digitalRead(pinSW_COL_1)) && !(digitalRead(pinSW_COL_2)) && !(digitalRead(pinSW_COL_3))){
        break;
        }
      }
  clearLCD();
  LCD.printf("switch %d PASSED", SW);

. I am new at this forum and I did not think that it would be an English type of class checking for spelling and grammar,

If you don't check your spelling and grammar, you can be assured that the compiler will.

I understand that, but as I said, it was only an example. I did not compile that exact code.
I am still hoping for an answer to my question.

Can you please tell me how to check within 2 sec if this is pass.

I have no clue what "if this is pass" means.

After the while statement ends, because of the break statement or because of the timeout, you haven't a clue which reason caused the while loop to end. Why not?

      bool dumbAssPressedSwitch = false;
      while(millis() - start <= 2000)
      { 
        if((digitalRead(pinSW_COL_1)) &&
           !(digitalRead(pinSW_COL_2)) &&
           !(digitalRead(pinSW_COL_3)))
        {
           dumbAssPressedSwitch = true;
           break;
        }
      }

      if(dumbAssPressedSwitch)
      {
         // What do you know - the dumb ass pressed a switch
      }
      else
      {
         // Dumb ass off taking a leak I guess
      }

EVERY { belongs on a new line.
EVERY line in a block is supposed to be indented.
It is OK (and even preferred) to break long statements up.

There is a simple user-input system in Planning and Implementing a Program. It may give you some ideas.

...R