If sensor is on for a certain duration, then do this?

Hi, I'm new to the forum and this is my first post.

In order to quiet down the noise coming from an IR sensor, I would like to say something along the lines of :

if ( sensor < somevalue for .5 seconds){

do this thing
}
else {you get the point}

My problem is, I don't know how to put this into any form of code. All I ask is that you please don't flat out give the answer, but hint at it ... if that makes any sense. thank you in advance

Start a timer when the sensor is active.

Use millis() time stamps.

If you don't want to see the answer then skip the following:

//  pirtrippoint5sec
//
//  wait for 5 seconds
//  of constant detection
//  ** works  07APR2014 **

unsigned long refTime;
unsigned long trippoint;

const long threshold = 5000;

byte DET;
const byte pirPin = 8;
const byte ledPin = 13;

void setup ()
{
  //pirPin is INPUT by default, use ExtPullup
  pinMode (ledPin,OUTPUT);
  digitalWrite (ledPin,LOW);
}

void loop ()
{
  DET = digitalRead(pirPin);
  if (DET == 1)  // inactive
  {
    refTime = millis();
    trippoint = refTime;
  }
  else   // Active Low
  {
    pir_active();
  }
}

void pir_active ()
{
  trippoint = millis();
  if ((trippoint-refTime) > threshold)
  {
    digitalWrite(ledPin,HIGH);
  }
}

Thanks for the replies, i think i get the millis () thing [will utilize soon] , but I was wondering why this doesn't seem to work :

if (sensor = active){

delay(someamountofseconds)
do the thing

}

else...

helpme222:
Thanks for the replies, i think i get the millis () thing [will utilize soon] , but I was wondering why this doesn't seem to work :

if (sensor = active){

delay(someamountofseconds)
do the thing

}

else...

you test the state for an instant in time. Then, you do nothing for a long period of time. Do you expect that your sensor remains unchanged during the time when you delay()? No, certainly not.

go with the millis() thingy.

Also, this is incorrect syntax

if (sensor = active){

it should be

if (sensor == active){

Note the ==

...R