Create a gist now

Instantly share code, notes, and snippets.

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
//set current time
int hours = 12;
int minutes = 31;
int seconds = 0;
// the loop routine runs over and over again forever:
void loop() {
//increment by seconds and cascade down
seconds = seconds + 1;
minutes = minutes + (seconds/60);
hours = hours + (minutes/60);
//reset when over 60, 12 etc
seconds = seconds % 60;
minutes = minutes % 60;
hours = hours % 12;
//print the time
Serial.print(hours);
Serial.print(":");
Serial.print(minutes);
Serial.print(":");
Serial.print(seconds);
Serial.println("");
//wait 1 second
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment