Created
July 12, 2017 07:25
-
-
Save JarekParal/72ee0de0f50bacdbfdffd1a9d1407d01 to your computer and use it in GitHub Desktop.
Clock - example 1
This file contains hidden or 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
#include "LearningKit.h" | |
int hour, min, sec; | |
void setup() { | |
Serial.begin(115200); | |
setupLeds(); | |
setupRgbLed(); | |
hour = 17; | |
min = 29; | |
sec = 0; | |
} | |
void loop() { | |
sec = sec + 1; | |
delay(1000); | |
if(sec == 60) { | |
//min = min + 1; | |
min += 1; | |
sec = 0; | |
} | |
if(min == 60) { | |
//hour = hour + 1; | |
hour++; | |
min = 0; | |
} | |
if(hour == 24) { | |
hour = 0; | |
} | |
// Serial.print(hour); | |
// Serial.print(":"); | |
// Serial.print(min); | |
// Serial.print(":"); | |
// Serial.println(sec); | |
Serial.printf("%2i:%02i:%02i\n", hour, min, sec); | |
if((hour == 17) && (min == 30)) { | |
digitalWrite(L_R, HIGH); | |
} else { | |
digitalWrite(L_R, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment