const int puerta = 2;
const int reset = 3;
const int luz = 5;
const int dalarma = 5000; 
unsigned long palarma = 0;
bool apuerta = false;
void setup() {
  pinMode(puerta, INPUT);
  pinMode(reset, INPUT);
  pinMode(luz, OUTPUT);
}

void loop() {
  bool epuerta = digitalRead(puerta);
  bool ereset = digitalRead(reset);
  if (epuerta == LOW && !apuerta) {
    palarma = millis();
    apuerta = true;
  }
  if (apuerta && (millis() - palarma >= dalarma)) {
    digitalWrite(luz, HIGH);
  }
  if (ereset == LOW) {
    digitalWrite(luz, LOW);
    apuerta = false;
  }
}