     pinMode(GREEN_LED, OUTPUT); 
     pinMode(YELLOW_LED, OUTPUT);
     digitalWrite(YELLOW_LED, HIGH);
-   digitalWrite(GREEN_LED, HIGH);
-  digitalWrite(RED_LED, HIGH); 
-  delay(2000);
-  
+    digitalWrite(GREEN_LED, HIGH);
+    digitalWrite(RED_LED, HIGH); 
+    delay(2000);
   #endif
   #ifdef USELCD
     ClearScreen();
     lcdSerial.write("Please scan card");
   #endif
+  Stop = true;
 }
 
 
 void loop()
 {
+  CountDownTimer(); // run the timer
+  if (TimeHasChanged()) 
+  { 
+    #ifdef DEBUG
+      Serial.print(ShowHours());
+      Serial.print(":");
+      Serial.print(ShowMinutes());
+      Serial.print(":");
+      Serial.print(ShowSeconds());
+      Serial.print(":");
+      Serial.print(ShowMilliSeconds());
+      Serial.print(":");
+      Serial.println(ShowMicroSeconds());
+    #endif
+    
+    // This DOES NOT format the time to 0:0x when seconds is less than 10.
+    // if you need to format the time to standard format, use the sprintf() function.
+    if(Stop == true)
+    {
+      #ifdef DEBUG
+        Serial.println("Stop reached");
+      #endif
+      #ifdef USELED
+     
+      #endif 
+       digitalWrite(RELAY1,HIGH);
+    }
+  }
+   
       int gotCard = 0;
       String serial;
       String pin ="";

      
                // Stop and disable RFID
          mfrc522.PICC_HaltA();
          AccessResponse accessResponse;
          
          #ifdef USEWEBAUTHENTICATE

          #endif         
          if(strcmp(accessResponse.AccessAllowed,"true")==0)
          {
               storedSerial = serial;
               
               #ifdef DEBUG
                 Serial.println("Stored" + storedSerial);
               #endif
               
               #ifdef USELED
                 TurnOnLED(GREEN_LED);
               #endif
               #ifdef USETONE
                  tone(TONEPIN,300,1000);
