unsigned long timerPreset;
unsigned long timerVal;
const uint8_t sensor6button = 11;
const uint8_t LED = 5;
void setup() {
pinMode(sensor6button, INPUT_PULLUP);
pinMode(LED, OUTPUT); // wired as common anode
timerPreset = 1500;
}
void loop() {
// as long as button is pressed, reset the timer
//
if(digitalRead(sensor6button) == LOW)
timerVal = millis();
// if button is not pressed the timer increments to preset
//
if(millis()-timerVal > timerPreset) digitalWrite(LED, HIGH); // LED off
else digitalWrite(LED,LOW); // LED on
}