add a automatic code to this sketch

Hello

I wonder if someone here can help me to add a automatic code to this sketch.

Sketch is working i use a keypad but only button 5 and 7 is in use.

When i power on arduino,i want automatic hold button 5 down in 4 seconds and then released,without i push the button manually down.

#include <Keypad.h>                                     // Keypad
#include <EasyTransfer.h>                               // Rs-422/485 
EasyTransfer Transfer;                                  // Rs-422/485
//******************************************************************************
// Keypad
//******************************************************************************
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] = {5, 4, 3, 2}; // connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6};     // connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

//****************************************************************************
// Setup
//****************************************************************************
boolean enable = true;
boolean enabled = true;
boolean relay_1 = false;
boolean relay_2 = false;
unsigned long lastSend = 0;
unsigned long currentTime;
int sendInterval = 75;
unsigned long previousMillis = 0;
unsigned long interval = 1500;
int ledPin = 9;
int ledState = LOW;

//****************************************************************************
// Rs-422/485 - receiver Setup
//****************************************************************************
struct rovData
{
        int relay1;
	int relay2;

}data;
//***************************************************************************
void setup()
//***************************************************************************
{
 Serial.begin(57600);
 Transfer.begin(details(data), &Serial);
 pinMode(ledPin, OUTPUT);
 keypad.addEventListener(keypadEvent); // Keypad 
}
//**************************************************************************
void loop()
//**************************************************************************
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval)
    {
      previousMillis = currentMillis;
      if(ledState == LOW)
      {
         ledState = HIGH;
      }
      else
      {
        ledState = LOW;
      }
       digitalWrite(ledPin, ledState);
      }
       
 char key = keypad.getKey();       
}
//*************************************************************************
inline void keypadEvent(KeypadEvent key){
//*************************************************************************
	switch (keypad.getState()){
		case PRESSED:
			switch (key){

		      
                               case '5': data.relay1   = 1; break;
                               case '7': data.relay2   = 1; break;
                           
                           }
		      break;
		case RELEASED:
			switch (key){
		          
                               case '5': data.relay1   = 0; break;
                               case '7': data.relay2   = 0; break; 
                         
                               }
			break;
		case HOLD:

			break;
        
 }    
}
//*********************************************************************************
inline void readkey()
//*********************************************************************************
{
    currentTime = millis();
    if(currentTime - lastSend > sendInterval)
    {
      lastSend = currentTime;
      if(enable == true)
      {
        Transfer.sendData();
      }
    }
}

Write everything that button 5 does as a function. Then call that function in a loop for 5 seconds, at the beginning of your setup().

In your loop(), when button 5 is pressed, call the function one time.

Paul

Also posted at http://forum.arduino.cc/index.php?topic=499416