a flag can not function

Hi,
I am working on a peizo sensor project:
when I press the sensor, I need to produce a HIGH flag.
Actually I have achieved the goal in previous version code. Now I just want to hold the flag for 1 second if the flag is produced. But the flag didn't work.
I don't know what happen on my code. My Code is as the following:

#include <avr/interrupt.h>
#include <stdlib.h>
#include <LiquidCrystal.h> //LCD Library

int led =13;
const int N=100;
float voltageValue[N];
float voltage[N];
boolean PressStatus;//Pressing flag;

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); //define lcd

//define Sinewave
char sinetable [32];
int  j ;

void ioinit (void)
{
  //Initialize output ports
  PORTD = B11111111;
  DDRD  = B11111111;

}

void timer_setup(){
  TCCR2A = 0;
  TCNT2=455;    //455 outputs 1.007khz
  TCCR2B = B00000010;
  //Timer2 Overflow Interrupt Enable
  TIMSK2 = 1<<TOIE2;
}


void setup(){
  ioinit();
  arraysetup();
  cli();
  timer_setup();
  j = 0;
  sei();



  //initialize serial communication at 4800bit per second;
  Serial.begin(4800);
  pinMode (led,OUTPUT);


  //Set Up LCD Display
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();    // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Welcome To SPS!"); 
  delay(3000);
  lcd.clear();    // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Voltage of Sensor:");    // change this text to whatever you like. keep it clean.

}

void arraysetup(void){
  sinetable[0]=127;  // Put 32 step 8 bit sine table into array.
  sinetable[1]=152;
  sinetable[2]=176;
  sinetable[3]=198;
  sinetable[4]=217;
  sinetable[5]=233;
  sinetable[6]=245;
  sinetable[7]=252;
  sinetable[8]=254;
  sinetable[9]=252;
  sinetable[10]=245;
  sinetable[11]=233;
  sinetable[12]=217;
  sinetable[13]=198;
  sinetable[14]=176;
  sinetable[15]=152;
  sinetable[16]=128;
  sinetable[17]=103;
  sinetable[18]=79;
  sinetable[19]=57;
  sinetable[20]=38;
  sinetable[21]=22;
  sinetable[22]=10;
  sinetable[23]=3;
  sinetable[24]=0;
  sinetable[25]=3;
  sinetable[26]=10;
  sinetable[27]=22;
  sinetable[28]=38;
  sinetable[29]=57;
  sinetable[30]=79;
  sinetable[31]=103;
}

void loop(){
  int i;
  for(i=0;i<N;i++){
    //read the input on analog pin A0;
    voltageValue[i] = analogRead(A0);
    voltage[i] = voltageValue[i] * (5.0 / 1023.0);

    if (i>0&&voltage[i]-voltage[i-1]>=0.03){

      float time=millis();
      if (time>500){
        PressStatus=0;
        digitalWrite(led,LOW);
      }
      else{
        PressStatus=1;
        digitalWrite(led,HIGH);
      }

    }

    else {
      PressStatus=0;
      digitalWrite(led,LOW);
      lcd.setCursor(0,1);
      lcd.print(voltage[i],3);
    }

    Serial.println(voltage[i]);
    //Serial.println(Press);
  }

}

//call SineWave generator function
ISR(TIMER2_OVF_vect) {
  if (PressStatus==1){
    PORTD=(sinetable[j++]);
    TCNT2=455;
    if(j==32){
      j=0;
    }
  }
}
      float time=millis();

Back to the documentation for you. millis() does NOT return a float.

void setup()
{
  // snipped some stuff
  delay(3000);
  // snipped some more stuff
}

void loop()
{
  // snipped some more stuff
      float time=millis();
      if (time>500)
      {

After diddling around in setup for 3000 milliseconds, how can millis() possibly return a value less than 3000?

but the "delay(3000)" is executed at the "setup" and the "time =millis()" is executed at the "loop". What can i do? I just need to remove "delay(3000)" if I want to hold the flag for 1 second?

Big Thank you!

millis() is not reset when setup() ends.

What would YOU do if someone said "Meet me at the bar an hour from now, and I'll buy you a drink". If you look at your watch and see that it is 12:30, would you say "Shit, I need a new watch, because this one doesn't show straight up 12:00, so I can't add an hour to it to determine when to be at the bar". Of course not. You know how to compute an absolute time from a relative time.

Similarly, if that person arrives at the bar an hour and 10 minutes later, and apologizes for being late, and asks how long you've been waiting, you can determine a relative time from two absolute times.

All you have on the Arduino is a way of getting relative times - relative to when the Arduino started running. Well, that is all your watch is telling you. The time that is shows is relative to some arbitrary point chosen a long time ago. And, yet, you manage to function quite well with it.

Learn to do the same with the relative times that the Arduino gives you.

Hi Pauls,
You mean the code "millis()" count the time when the code is running?
can you give me an example which displays a relative time?
Thanks

You mean the code "millis()" count the time when the code is running?

It counts the time since the Arduino was reset.

can you give me an example which displays a relative time?

Serial.print(millis());