How do I use a switch with a 30 second delay

Float Switch to delay 30 seconds after it has been pressed, while the water drains completly.... pump will turn back on after the 30 seconds...... and the process repeats itself ....

I used the button example the arduino software provides,then included a delay in the sequence. The delay ruins the process.

      const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
delay(30000);
  }
}

I used the button example the arduino software provides,then included a delay in the sequence. The delay ruins the process.

To the Arduino, 30 seconds is an eternity. So, think about how YOU would perform the task, if the interval was 30 hours, instead of 30 seconds.

You'd note when the switch was pressed, and the continue drinking beer, sleeping, watching TV, etc. Periodically, you'd look at your watch, and determine if 30 hours had passed. If it had, you'd do whatever needs to be done. If not, resume watching TV, etc.

Look at the blink without delay example to see how to get the Arduino to do what you would need to do.

Thanks

you can still delay the action. do not use delay to do it. use millis(). by using delay it stops the program for 30 seconds. millis() will allow the program to keep running.