Hi,
I'm communicating with an arduino over a serial connection, and one of the function in my sketch sends back some condensed information to the computer. After ~10 hours, the calculated minutes on the arduino appears to overflow.
I've attached a screen shot of the resulting printout in PuTTY.
////////////////////////////////////////////////
// Statuser - Sends system status to Serial
/////////////////////////////////////////////
int statuser ()
{
wdt_reset();
Serial.println("$");
Serial.println("[Start]"); //Start Of Transmission
delay(15);
unsigned long currentSeconds = (millis()/1000);
refresh();
Serial.print("-Time Alive: ");
int hr = (currentSeconds/3600);
int mn = (((currentSeconds)-(hr*3600))/60);
int sc = ((currentSeconds)-((hr*3600)+(mn*60)));
Serial.print(hr);
Serial.print(":");
Serial.print(mn);
Serial.print(":");
Serial.println(sc);
Serial.print("-Num of Program Cycles: ");
Serial.println(progCycles);
Serial.print("-Avg Cycles per Second: ");
int cps = (progCycles/(currentSeconds));
Serial.println(cps);
Serial.print("-DoorState: ");
Serial.println(doorState);
Serial.print("-Bitch Seconds: ");
if (bitchTime == 0)
{
Serial.println("Not Active"); // The timer isn't running
}
else
{
Serial.println((bitchTime - millis()) / 1000); // Print the number of seconds left before the door locks
}
Serial.print("-Servo Position: ");
Serial.println(servState);
Serial.print("-Last Serial Byte: ");
Serial.println(lastSerial);
delay(15);
Serial.println("[End]"); //End Of Transmission
return(0);
}
I'd appreciate any input on what may be causing the problem, or suggestions on debugging.
Thanks,
-BBX