The one problem with Crossroad's approach is that it won't detect if the sensor went back to HIGH in that one second. So it doesn't really check that the sensor was LOW for the second only that it is still LOW after.
I'd handle it much like reading a switch. Using state change detection. It's similar to debouncing.
int currentSensorState;
int lastSensorState;
unsigned long readTimer;
void loop() {
unsigned long currentMillis = millis();
// I'll assume you read the sensor something like this
currentSensorState = digitalRead(SENSOR_PIN);
// check for change from last state
if (lastSensorState != currentSensorState)
{
lastSensorState = currentSensorState; // store the change
readTimer = currentMillis; // start the timer
}
// check if timing and if timing finished
if (readTimer > 0 && currentMillis - readTimer >= 1000)
{
// reset timer
readTimer = 0;
// If it makes it here it has been in the new state for a second
if (currentSensorState == LOW)
{
// do stuff for LOW state
}
else
{
// do stuff for HIGH state if you want
}
}
}
If, at any time during the one second, the sensor's state changes the readTimer will be set to a new millis() value and the timer will start again. Thus the sensor will have to be LOW for the entire second to pass.