PaulS:
unsigned long duration = millis() - highAt;
if(duration >= 500 && duration < 2000)
{
//Serial.println("between 500 and 1990");
}
else if(duration >= 2000 && duration < 3000)
{
//Serial.println("above 2999");
}
Of course, that last commented out Serial.print() statement is nonsense...
Cheers, I have tried to use your code, it works to some extent, but after the operation is executed and "timings" it should reset the timing to ZERO, so that it can run in a loop, but it does not
// if the sensor input goes above the Redline start measuring the time...
if(Sensor.getProximity() > Redline){
duration = millis() - highAt;
Serial.print(duration/1000);
// check for timings
if(duration >= 500 && duration < 2000)
{
Serial.println("between 500 and 1990");
}
else if(duration >= 2000 && duration < 3000)
{
Serial.println("above 2999");
}
else if(Sensor.getProximity() < Redline){
Serial.print("reset clock");
duration = 0;
highAt = 0;
}
}