int lowEnd = 280; //the low end of the proximity reading
int highEnd = 1100; //the high end of the proximity reading

void setup()
{
pinMode(pinOut, OUTPUT);
}

void loop()
{
int val = 0;

val = readVal(sensor);

//the following condition forces the target to be in porximity for a set amount of time
if(isValid(val))
{
counter++;
}
else
{
if(counter>0)
{
counter–;
}
}
delay(300); //wait 1/3 of a second :: 10/30 frames to initialize another sampling