Timer problem

Hi.

In my project, I have an event (knocking a piezo).
I would do something like :

I tried this way :

timeToCheck = millis();
  toc = analogRead(piezo);
  if (toc > minToc)
    {
    check(); //check the button state and if pressed, set hit = 1 [the "something" in the pic]
    while (millis() - timeToCheck < 1000);
    
    if (hit == 0)
    {
      fail(); [the "something else" in the pic]
    }

But if the button is pressed, nothing happends, it's acting the same way that I didn't pressed it.

Any suggestion ?

[edit]
The pic is too big, here is the link http://img4.hostingpics.net/pics/579840timerArduino.png

Any suggestion ?

Yes. Post you whole program

#include <Servo.h>
Servo servo;
const unsigned int piezo = A0;
const unsigned int buttonServo = 7;
const unsigned int greenLed = 8;
const unsigned int redLed = 10;
const unsigned int angleDown = 95;
const unsigned int angleTop = 0;
unsigned long timeToCheck;
unsigned int minToc = 100;
unsigned int toc;
boolean hit = 0;

void setup()
{
  servo.attach(9);
  pinMode(buttonServo, INPUT);
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  Serial.begin(9600); //debug
}

void loop()
{
  timeToCheck = millis();
  toc = analogRead(piezo);
  if (toc > minToc)
    {
    check();
    while (millis() - timeToCheck < 1000);
    
    if (hit == 0)
    {
      fail();
    }
  }

  
}

void check()
{
 if (digitalRead(buttonServo) == HIGH)
 {
   but();
  } 
}


void but()
{
  hit = 1;
  digitalWrite(greenLed, HIGH);
  Serial.println("BING!");
  servo.write(angleTop);
  delay(200);
  servo.write(angleDown);
  delay(1500); //random?
  digitalWrite(greenLed, LOW);
  hit = 0;
}

void fail()
{
  Serial.println("FAIL :(");
  digitalWrite(redLed, HIGH);
  delay(1700);
  digitalWrite(redLed, LOW);  
}

    while (millis() - timeToCheck < 1000);Because of the semi-colon your program will execute this while loop for one second during which it will do nothing else.

You need to check whether the button is pressed within the while loop and take action as appropriate.

Thanks!
Problem solved like this:

#include <Servo.h>
Servo servo;
const unsigned int piezo = A0;
const unsigned int buttonServo = 7;
const unsigned int greenLed = 8;
const unsigned int redLed = 10;
const unsigned int angleDown = 95;
const unsigned int angleTop = 0;
unsigned long timeToCheck;
unsigned int minToc = 100;
unsigned int toc;
boolean hit = 0;

void setup()
{
  servo.attach(9);
  pinMode(buttonServo, INPUT);
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  Serial.begin(9600); //debug
}

void loop()
{

  hit = 0;
  timeToCheck = millis();
  toc = analogRead(piezo);
  if (toc > minToc)
  {
    while (millis() - timeToCheck < 1000)
    {
      if (digitalRead(buttonServo) == HIGH)
      {
        goal();
      } 
    }
    if (hit == 0)
    {
      fail();
    }
  }
}

void goal()
{
  hit = 1;
  digitalWrite(greenLed, HIGH);
  Serial.println("BING!");
  servo.write(angleTop);
  delay(200);
  servo.write(angleDown);
  delay(1500); //random?
  digitalWrite(greenLed, LOW);
}

void fail()
{
  Serial.println("FAIL :(");
  digitalWrite(redLed, HIGH);
  delay(1700);
  digitalWrite(redLed, LOW);  
}