[SOLVED]Kind of while loop for enable system

Thanks blues eyes that has give me the idea how to do it and very well explained.

I've studied your code and can follow it, There msut be a little glitch as I've added the pins in set up to suit added an LED to show what's going on.

It works as described so when I move the joystick the LED remains on, If I just press the enable button it does not count for 5 seconds as I would thought it would the LED just goes straight out on once enable button released.

Which I'm looking into to get to understand the ocde better and hopefully get to the bottom of

Here's my code

unsigned long Timer = 5000;
unsigned long Timer_currentMillis = 0;


#define Enable_button 5
#define FWD_UP  3 //forward signal from joystick
#define REV_DN 4 //reverse signal from joystick
boolean FWD_UP_DAT = 0; //set the forward signal to 0
boolean REV_DN_DAT_DAT = 0;//set backwards siganl to 0
#define Error_led A3
bool enabled = false;

void setup() {
  pinMode(Error_led, OUTPUT);
  digitalWrite(Error_led, LOW);
  pinMode(FWD_UP, INPUT_PULLUP);
  pinMode( REV_DN, INPUT_PULLUP);
  pinMode(Enable_button, INPUT_PULLUP);
}

void loop() {

  FWD_UP_DAT     = digitalRead(FWD_UP); //Drive forward signal
  REV_DN_DAT_DAT    = digitalRead( REV_DN); //Drive Reverse signal

  // if joystick active
  if ( (FWD_UP_DAT == LOW) || (REV_DN_DAT_DAT == LOW) )
  {
    // reset timer
    Timer_currentMillis = millis();

  } else if ( enabled ) {   // joystick not active, enable set - check timeout

    // if timer is up clear enabled flag
    enabled =  (millis() - Timer_currentMillis) >= Timer;

  } // else if

  // if not enabled and enable button is pressed
  if ( !enabled && (digitalRead( Enable_button) == LOW) )
  {
    // set flag
    enabled = true;

    // set timer
    Timer_currentMillis = millis();

  } // if


  if ( enabled )
  {
    //send data out from joystick
    digitalWrite(Error_led, HIGH);

  }
  else {
    //stop sending data out and turn off timer
    digitalWrite(Error_led, LOW);
  }


}

Once again thanks for the guidance and your time
Steve