Led on after interval, off after button push

Hi,
After an certain interval I want a red led to turn on. Pushing a button must turn the red led off and the interval starts again. I tried several things but I can’t get it to work. In the sketch the led toggles but the interval doesn’t work. How can I fix this?

int inPin = 2;         
int outPin = 13;       
int greenPin = 8;

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

unsigned long previousMillis = 0; // 
unsigned long currentMillis = 0; // 
const long interval = 2000 ; // 

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}
void loop()
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    stepDing ();
  }
  else
  {
    digitalWrite (greenPin, HIGH);
  }
}
void stepDing()
{
  digitalWrite (greenPin, LOW); 
  while(digitalRead(outPin == HIGH))
  {
    reading = digitalRead(inPin);
    if (reading == HIGH && previous == LOW ) {
      if (state == HIGH)
        state = LOW;
      else
        state = HIGH;  
    }
    digitalWrite(outPin, state);
    previous = reading;

  }
  previousMillis = currentMillis; 
}
 while(digitalRead(outPin == HIGH))

13 != 1 means you'll always read pin zero.

Adding digitalWrite (outPin, HIGH) in the beginning of void stepDing makes no difference. Is this what you mean?

No, I mean while(digitalRead(outPin) == HIGH) See the difference?

(Though why you're reading a pin called "outPin" escapes me)

What about this (not tested) I reckon it is significantly simpler - most times I have problems they are solved by taking stuff out. If it works, study the changes carefully. It's also possible it works but is back-to-front (on when it should be off) - just swap HIGH and LOW

int inPin = 2;         
int outPin = 13;       
int greenPin = 8;

int state = LOW;      // the current state of the led
int reading;           // the current reading from the input pin

unsigned long previousMillis = 0; // 
unsigned long currentMillis = 0; // 
const long interval = 2000 ; // 

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}
void loop()
{
  currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    state = HIGH;
  }
  reading = digitalRead(inPin);
  if (reading == HIGH && state == LOW) {
    state = HIGH;
    previousMillis = currentMillis; 
  }
  stepDing ();
}
void stepDing()
{
  digitalWrite (greenPin, state); 
}

...R

I am probably on the wrong track. The idea is that after the interval in the loop the outPin (pin 13, red led) is set high in the stepDing function. The while function checks whether pin 13 is high. In the while function pin 13 is set low or high by the button (inPin, 2). So when the button is pressed, outPin 13 goes LOW so the interval starts again? So far it doesn’t. I added the correction you suggested and made the outPin (13) high before the while loop. Pin 13 stays high but dims after button press. The interval does not work.

int inPin = 2;         
int outPin = 13;       
int greenPin = 8;

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

unsigned long previousMillis = 0; // 
unsigned long currentMillis = 0; // 
const long interval = 2000 ; // 

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}
void loop()
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    stepDing ();
  }
  else
  {
    digitalWrite (greenPin, HIGH);
  }
}
void stepDing()
{
  digitalWrite (greenPin, LOW); 
  digitalWrite (outPin, HIGH);
  while(digitalRead(outPin) == HIGH)
  {
    reading = digitalRead(inPin);
    if (reading == HIGH && previous == LOW ) {
      if (state == HIGH)
        state = LOW;
      else
        state = HIGH;  
    }
    digitalWrite(outPin, state);
    previous = reading;

  }
  previousMillis = currentMillis; 
}