Last active
December 28, 2015 02:09
-
-
Save chris-gunawardena/7425845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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