The Planted Tank Forum - View Single Post - Guide: Arduino based LED controller for Current Satellite LED+
View Single Post
post #344 of (permalink) Old 08-31-2013, 04:34 AM
Algae Grower
Join Date: Oct 2010
Location: Mississippi
Posts: 119
Here is the debug code I used. If you want to try it replace the loop() & syncprovider() functions with the ones below and add cseconds and pseconds to the global variables at the top somewhere.
unsigned int cseconds = 0;
unsigned int pseconds = 0;

void loop()
  cseconds = millis() / 1000;
  if (Serial.available() > 0) {
    delay(5); //Wait for transmission to finish
    TestCodes(SerialReadInt());  // Go grab IR code and send it
  Alarm.delay(100);   // Service alarms & wait (msec)
  fprintf(&lcdout, "%02d:%02d", hour(), minute());  // Print the time HH:MM to the lcd
  if (cseconds - pseconds >= 60)
    printf("Arduino Time: %02d:%02d:%02d\n", hour(), minute(), second());
    pseconds = cseconds;

time_t syncProvider()
  printf("Arduino sync'ed to RTC: %02d:%02d:%02d\n",,,;
Calling hour() or minute() inside syncProvider() locks the Arduino up, so I moved the Arduino time to loop() and did a counter to display it every minute.
Dahammer is offline  
For the best viewing experience please update your browser to Google Chrome