 -Fixing a bug caused by changing the RTC Lib.
 -Changing Time calculation from minutes to military.
 -Implementing Manual Mode in DEBUG mode.
+March 23, 2017:
+-Fixing a bug regarding checking "isAutoMode".
+-Improving code.
 */
 
 #include <DS1302.h>


void loop()
{
  isItAutoMode = digitalRead(13) == HIGH;
  int threshold = 60000; //In final product, the board will check and write every minute.
  #ifdef DEBUG
  threshold = 1000; //Under development, the board will check and write every second.
  //Serial.print("Is it automode? ");
  //Serial.println(isItAutoMode);
  #endif
  if (millis() - timer >= threshold)
  {

    digitalWrite(i, level);
    i += i == 9 ? 4 : 1; //Skip the RTC Pins (10, 11, 12).
  }
}
